springboot 연결 Oracle 데이터베이스 설정

1344 단어 SpringBoot
.properties     Oracle   

spring.datasource.oracle.jdbc-url=jdbc:oracle:thin:@IP:1521/   
spring.datasource.oracle.username=
spring.datasource.oracle.password=
spring.datasource.oracle.driver-class-name=oracle.jdbc.driver.OracleDriver
spring.datasource.oracle.maximum-pool-size=5



Hikari  Oracle   
	
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.core.JdbcTemplate;

import com.zaxxer.hikari.HikariDataSource;

@Configuration
public class OracleDataSourceConfig {
	  @Bean(name = "OracleDataSource")
	  @ConfigurationProperties(prefix = "spring.datasource.oracle")
	  public HikariDataSource dataSource() {
	    return (HikariDataSource) DataSourceBuilder.create().type(HikariDataSource.class).build();
	  }
	  
	  
	  @Bean(name="oracleJdbcTemplate")
	  public JdbcTemplate oracleJdbcTemplate(@Qualifier("OracleDataSource") HikariDataSource OracleDataSource){
			return new JdbcTemplate(OracleDataSource);
		}
}	
	
   :ojdbc7-12.1.0.2.jar(      ,    maven   ,         )

좋은 웹페이지 즐겨찾기