Advertisement
Guest User

Untitled

a guest
Apr 25th, 2016
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.45 KB | None | 0 0
  1. import java.sql.SQLException;
  2.  
  3. import javax.annotation.PostConstruct;
  4. import javax.sql.DataSource;
  5.  
  6. import oracle.jdbc.pool.OracleDataSource;
  7.  
  8. import org.springframework.beans.factory.annotation.Autowired;
  9. import org.springframework.beans.factory.annotation.Value;
  10. import org.springframework.boot.context.properties.EnableConfigurationProperties;
  11. import org.springframework.context.annotation.Bean;
  12. import org.springframework.context.annotation.ComponentScan;
  13. import org.springframework.context.annotation.Configuration;
  14. import org.springframework.context.annotation.PropertySource;
  15. import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
  16. import org.springframework.core.io.ClassPathResource;
  17. import org.springframework.core.io.Resource;
  18. import org.apache.commons.dbcp2.BasicDataSource;
  19. import org.springframework.stereotype.Component;
  20.  
  21. @Configuration
  22. @ComponentScan
  23. @PropertySource("classpath:application.properties")
  24. public class Config {
  25.  
  26. @Autowired
  27. private static SpringAppProp springAppProp;
  28.  
  29.  
  30.  
  31.  
  32.  
  33. @Value("${url}")
  34. private static String url;
  35.  
  36. @Value("${driverClassName}")
  37. private static String driverClassName;
  38.  
  39. @Value("${username}")
  40. private static String username;
  41.  
  42. @Value("${password}")
  43. private static String password;
  44.  
  45. @Value("${initialSize}")
  46. private static int initialSize;
  47.  
  48. @Value("${maxActive}")
  49. private static int maxActive;
  50.  
  51. @Value("${dbPort}")
  52. private static int dbPort;
  53.  
  54. @Value("${dbServiceName}")
  55. private static String dbServiceName;
  56.  
  57. @Value("${dbServer}")
  58. private static String dbServer;
  59.  
  60.  
  61.  
  62. @Bean
  63. public static PropertySourcesPlaceholderConfigurer placeholderConfigurer() {
  64. return new PropertySourcesPlaceholderConfigurer();
  65. }
  66. @Bean(name = "DataSource")
  67. public static BasicDataSource dataSource() throws SQLException {
  68. BasicDataSource basicDataSource = new BasicDataSource();
  69. basicDataSource.setUrl(url);
  70. basicDataSource.setDriverClassName(driverClassName);
  71. basicDataSource.setInitialSize(initialSize);
  72. basicDataSource.setMaxTotal(maxActive);
  73. basicDataSource.setMaxIdle(5);
  74. basicDataSource.setMinIdle(0);
  75. basicDataSource.setMaxWaitMillis(15000);
  76. return basicDataSource;
  77. }
  78.  
  79. }
  80.  
  81. server.port=8080
  82. driverClassName=oracle.jdbc.driver.OracleDriver
  83. username=XXXX
  84. password=XXXX
  85. initialSize=10
  86. maxActive=20
  87. dbPort=XXX
  88. dbServiceName=xxxx
  89. dbServer=xxxxxx
  90. url=jdbc:oracle:thin@//xxxxx
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement