import java.sql.SQLException; import javax.annotation.PostConstruct; import javax.sql.DataSource; import oracle.jdbc.pool.OracleDataSource; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; import org.apache.commons.dbcp2.BasicDataSource; import org.springframework.stereotype.Component; @Configuration @ComponentScan @PropertySource("classpath:application.properties") public class Config { @Autowired private static SpringAppProp springAppProp; @Value("${url}") private static String url; @Value("${driverClassName}") private static String driverClassName; @Value("${username}") private static String username; @Value("${password}") private static String password; @Value("${initialSize}") private static int initialSize; @Value("${maxActive}") private static int maxActive; @Value("${dbPort}") private static int dbPort; @Value("${dbServiceName}") private static String dbServiceName; @Value("${dbServer}") private static String dbServer; @Bean public static PropertySourcesPlaceholderConfigurer placeholderConfigurer() { return new PropertySourcesPlaceholderConfigurer(); } @Bean(name = "DataSource") public static BasicDataSource dataSource() throws SQLException { BasicDataSource basicDataSource = new BasicDataSource(); basicDataSource.setUrl(url); basicDataSource.setDriverClassName(driverClassName); basicDataSource.setInitialSize(initialSize); basicDataSource.setMaxTotal(maxActive); basicDataSource.setMaxIdle(5); basicDataSource.setMinIdle(0); basicDataSource.setMaxWaitMillis(15000); return basicDataSource; } } server.port=8080 driverClassName=oracle.jdbc.driver.OracleDriver username=XXXX password=XXXX initialSize=10 maxActive=20 dbPort=XXX dbServiceName=xxxx dbServer=xxxxxx url=jdbc:oracle:thin@//xxxxx