무회blog

spring MVC(모델2)방식,JAVA, MySQL , RESFUL, 게시판 만들기 , 001 (실행) 본문

IT/Spring

spring MVC(모델2)방식,JAVA, MySQL , RESFUL, 게시판 만들기 , 001 (실행)

최무회 2020. 8. 24. 08:50

실행 클래스-001

 

com.board

BoardApplication.java

package com.board;
 
import javax.sql.DataSource;
 
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jersey.JerseyProperties.Filter;
import org.springframework.context.annotation.Bean;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.web.filter.HiddenHttpMethodFilter;
 
@SpringBootApplication
@MapperScan(value = {"com.board.mapper"})
public class BoardApplication {
 
    public static void main(String[] args) {
        SpringApplication.run(BoardApplication.class, args);
    }
    
    /**
     * SqlSessionFactory 설정
     */
    @Bean
    public SqlSessionFactory sqlSessionFactory(DataSource dataSource)throws Exception{
        SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
            sessionFactory.setDataSource(dataSource);
            
            Resource[] res = new PathMatchingResourcePatternResolver().getResources("classpath:mappers/*Mapper.xml");
            
            sessionFactory.setMapperLocations(res);
            
            return sessionFactory.getObject();
    }
    
    /**
     * HiddenHttpMethodFilter  
     */
    @Bean
    public HiddenHttpMethodFilter hiddenHttpMethodFilter(){
        HiddenHttpMethodFilter filter = new HiddenHttpMethodFilter();
        return filter;
    }
    
}

 

참고: 

https://private.tistory.com/38?category=655784

 

스프링 부트 게시판 만들기4 - Rest방식의 게시글 목록/작성/수정/삭제

관련글 : 스프링 부트로 게시판 만들기1 - 프로젝트 생성 스프링 부트로 게시판 만들기2 - MyBatis, MySQL 연동 스프링 부트로 게시판 만들기3 - JSP 사용하기 사실 포스팅은 매일하는데 어제는 작성 완

private.tistory.com

 

Comments