Kaynağa Gözat

亿道次元EIS 【切换数据库链接为druid连接池】

xiaost 1 yıl önce
ebeveyn
işleme
1940b9676d

+ 16 - 5
pom.xml

@@ -41,11 +41,22 @@
 			<artifactId>spring-boot-starter-jdbc</artifactId>
 		</dependency>
 
-		<dependency>  
-            <groupId>org.springframework.boot</groupId>  
-            <artifactId>spring-boot-starter-data-jpa</artifactId>  
-        </dependency>
-	
+		<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>
 		    <artifactId>log4j</artifactId>

+ 2 - 5
src/main/java/com/uas/eis/UasEisApplication.java

@@ -1,20 +1,17 @@
 package com.uas.eis;
 
 import com.uas.eis.core.config.DataSourceProperties;
+import com.uas.eis.core.support.TokenPropertiesListener;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.boot.context.properties.EnableConfigurationProperties;
 import org.springframework.cache.annotation.EnableCaching;
-import org.springframework.context.annotation.Import;
 import org.springframework.scheduling.annotation.EnableScheduling;
 
-import com.uas.eis.core.config.DynamicDataSourceRegister;
-import com.uas.eis.core.support.TokenPropertiesListener;
-
 @SpringBootApplication
 @EnableCaching
 @EnableScheduling
-@Import({DynamicDataSourceRegister.class})
+/*@Import({DynamicDataSourceRegister.class})*/
 @EnableConfigurationProperties(DataSourceProperties.class)
 public class UasEisApplication {
 	public static void main(String[] args) {

+ 14 - 1
src/main/resources/application.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: YD_CYZZ
         password: select!#%*(
         url: jdbc:oracle:thin:@10.1.81.208:11701: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
     http:
         encoding:
             force: true