root-context.xml 사용 안하고, 자바 @configuration 사용함.
application.properties 파일
server.port=9999
server.servlet.context-path=/dmmybatis
spring.mvc.view.prefix=/WEB-INF/jsp/
spring.mvc.view.suffix=.jsp
#hikari CP -- SPRING BOOT에 이미 포함된 라이브러리
spring.datasource.hikari.driver-class-name=net.sf.log4jdbc.sql.jdbcapi.DriverSpy
spring.datasource.hikari.jdbc-url=jdbc:log4jdbc:oracle:thin:@localhost:1521:xe
spring.datasource.hikari.username=hr
spring.datasource.hikari.password=hr
spring.datasource.hikari.maximum-pool-size=10
DatabaseConfiguration.java 파일
package com.example.demo.configuration;
import javax.sql.DataSource;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
@Configuration
@PropertySource("classpath:/application.properties")
public class DatabaseConfiguration {
@Bean
@ConfigurationProperties(prefix="spring.datasource.hikari")
public HikariConfig hikariConfig() {
return new HikariConfig();
}
@Bean
public DataSource dataSource() throws Exception {
DataSource dataSource = new HikariDataSource(hikariConfig());
System.out.println(dataSource.toString());
return dataSource;
}
}
다른경로의 경우에는 꼭 @ComponentScan 어노테이션 경로를 설정해줘야함.
JSP사용 할때는 마켓플레이스에서 Eclipse Enterprise java and Web Developer Tools 설치하자
'KOSTA > SpringBoot' 카테고리의 다른 글
Spring Boot에서 CORS 적용해보기 (0) | 2021.08.13 |
---|---|
cascade , mappedBy, fetch (0) | 2021.08.12 |
SpringBoot - JPA(2) (0) | 2021.08.05 |
Spring - Qualifier설정, Repboard 병합, JPA (0) | 2021.08.04 |
STS 설치 및 설정, Junit5, Logger(logback) 설정 (0) | 2021.08.02 |