Browse Source

切换数据库链接为druid连接池

zhouy 2 years ago
parent
commit
880fa93a8e

+ 14 - 3
pom.xml

@@ -41,10 +41,21 @@
 			<artifactId>spring-boot-starter-jdbc</artifactId>
 		</dependency>
 
-		<dependency>  
-            <groupId>org.springframework.boot</groupId>  
-            <artifactId>spring-boot-starter-data-jpa</artifactId>  
+		<dependency>
+			<groupId>org.springframework.boot</groupId>
+			<artifactId>spring-boot-starter-jdbc</artifactId>
+		</dependency>
+
+		<dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-data-jpa</artifactId>
         </dependency>
+
+		<dependency>
+			<groupId>com.alibaba</groupId>
+			<artifactId>druid-spring-boot-starter</artifactId>
+			<version>1.2.6</version>
+		</dependency>
 	
 		<dependency>
 		    <groupId>log4j</groupId>

+ 1 - 1
src/main/java/com/uas/eis/UasEisApplication.java

@@ -12,7 +12,7 @@ import com.uas.eis.core.support.TokenPropertiesListener;
 @SpringBootApplication
 @EnableCaching
 @EnableScheduling
-@Import({DynamicDataSourceRegister.class})
+/*@Import({DynamicDataSourceRegister.class})*/
 public class UasEisApplication {
 	public static void main(String[] args) {
 		SpringApplication application = new SpringApplication(UasEisApplication.class);

+ 14 - 1
src/main/resources/application-prod.yml

@@ -1,10 +1,23 @@
 spring:
     datasource:
-        type: org.apache.tomcat.jdbc.pool.DataSource
+        type: com.alibaba.druid.pool.DruidDataSource
         driverClassName: oracle.jdbc.OracleDriver
         username: DATACENTER_KX
         password: select!#%*(
         url: jdbc:oracle:thin:@10.100.100.25:1521:orcl
+        initialSize: 1
+        maxActive: 3
+        maxWait: 30000
+        testOnBorrow: false
+        testOnReturn: false
+        testWhileIdle: true
+        validationQuery: SELECT 1 FROM DUAL
+        timeBetweenEvictionRunsMillis: 60000
+        removeAbandoned: true
+        removeAbandonedTimeout: 1800
+        minEvictableIdleTimeMillis: 300000
+        poolPreparedStatements: true
+        maxPoolPreparedStatementPerConnectionSize: 3
 server:
     tomcat:
         uri_encoding: UTF-8