完成项目与druid-springboot的集成测试
This commit is contained in:
-1
@@ -1,7 +1,6 @@
|
||||
package com.micro.fast.security.core.browser.config.param;
|
||||
|
||||
import com.micro.fast.security.core.browser.constant.LoginType;
|
||||
import org.hibernate.validator.constraints.NotBlank;
|
||||
|
||||
/**
|
||||
* 浏览器身份认证配置参数
|
||||
|
||||
+2
-1
@@ -2,8 +2,8 @@ package com.micro.fast.security.core.master;
|
||||
|
||||
import com.micro.fast.security.core.browser.config.param.BrowserProperties;
|
||||
import com.micro.fast.security.core.validate.code.config.param.ValidateCodeProperties;
|
||||
import org.omg.CORBA.PRIVATE_MEMBER;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
@@ -12,6 +12,7 @@ import javax.validation.Valid;
|
||||
* @author lsy
|
||||
*/
|
||||
@ConfigurationProperties(prefix = "ms.security")
|
||||
@Configuration
|
||||
public class SecurityProperties {
|
||||
/**
|
||||
* 浏览器身份认证配置
|
||||
|
||||
-2
@@ -6,7 +6,6 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Conditional;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
@@ -17,7 +16,6 @@ import javax.sql.DataSource;
|
||||
@AutoConfigureBefore(com.micro.fast.common.config.DynamicDataSourceConfig.class)
|
||||
public class DruidDataSourceConfig {
|
||||
|
||||
@Primary
|
||||
@Bean(name = DynamicDataSourceConfig.MASTER_DATA_SOURCE)
|
||||
@ConfigurationProperties("spring.datasource.druid.master")
|
||||
@Conditional(com.micro.fast.common.condition.MasterDataSourceCondition.class)
|
||||
|
||||
+9
-4
@@ -4,6 +4,7 @@ import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure;
|
||||
import com.micro.fast.common.dao.DynamicDataSource;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
@@ -22,12 +23,14 @@ import java.util.Map;
|
||||
* @since 1.0
|
||||
*/
|
||||
@Configuration
|
||||
@AutoConfigureBefore({SqlSessionFactoryConfig.class, DruidDataSourceAutoConfigure.class})
|
||||
@AutoConfigureBefore({SqlSessionFactoryConfig.class})
|
||||
@AutoConfigureAfter({DruidDataSourceAutoConfigure.class})
|
||||
public class DynamicDataSourceConfig {
|
||||
public static final String SLAVE = "slave";
|
||||
public static final String MASTER = "master";
|
||||
public static final String MASTER_DATA_SOURCE = "masterDataSource";
|
||||
public static final String DATA_SOURCE = "dataSource";
|
||||
public static final String DYNAMIC_DATA_SOURCE = "dynamicDataSource";
|
||||
|
||||
/**
|
||||
* 当dataSource存在时
|
||||
@@ -48,7 +51,7 @@ public class DynamicDataSourceConfig {
|
||||
@Autowired
|
||||
private Map<String,DataSource> dataSourceMap;
|
||||
|
||||
@Bean(name = "dataSource")
|
||||
@Bean(name = DYNAMIC_DATA_SOURCE)
|
||||
@Primary
|
||||
public DataSource dynamicDataSource(){
|
||||
//动态数据源对象
|
||||
@@ -60,7 +63,8 @@ public class DynamicDataSourceConfig {
|
||||
dynamicDataSource.setDefaultTargetDataSource(dataSource);
|
||||
dataSourceMap.put(MASTER,dataSource);
|
||||
this.dataSourceMap.forEach((key,value) -> {
|
||||
if ( !DATA_SOURCE.equals(key)
|
||||
if ( DYNAMIC_DATA_SOURCE.equals(key)
|
||||
&&!DATA_SOURCE.equals(key)
|
||||
&& !MASTER.equals(key)){
|
||||
dataSourceMap.put(key,value);
|
||||
}
|
||||
@@ -72,7 +76,8 @@ public class DynamicDataSourceConfig {
|
||||
dataSourceMap.put(MASTER,masterDataSource);
|
||||
dataSourceMap.put(SLAVE,dataSource);
|
||||
this.dataSourceMap.forEach((key,value) -> {
|
||||
if (!DATA_SOURCE.equals(key)
|
||||
if (DYNAMIC_DATA_SOURCE.equals(key)
|
||||
&&!DATA_SOURCE.equals(key)
|
||||
&&!MASTER_DATA_SOURCE.equals(key)
|
||||
&& !MASTER.equals(key)
|
||||
&& !SLAVE.equals(key)){
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
package com.micro.fast.ucenter;
|
||||
|
||||
import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||
import org.springframework.cloud.client.SpringCloudApplication;
|
||||
import org.springframework.cloud.netflix.feign.EnableFeignClients;
|
||||
|
||||
@SpringCloudApplication
|
||||
@EnableFeignClients
|
||||
@MapperScan(basePackages = {"com.micro.fast.ucenter.dao"})
|
||||
@EnableAutoConfiguration(exclude = DruidDataSourceAutoConfigure.class)
|
||||
@EnableAutoConfiguration(exclude = DataSourceAutoConfiguration.class)
|
||||
public class UcenterApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
@@ -11,10 +11,10 @@ spring:
|
||||
username: config
|
||||
password: server
|
||||
datasource:
|
||||
username: root
|
||||
password: studyj2e
|
||||
url: jdbc:mysql://127.0.0.1:3317/micro?useUncoide=true&chracterEncoding=utf-8&useSSL=false
|
||||
druid:
|
||||
username: root
|
||||
password: studyj2e
|
||||
url: jdbc:mysql://127.0.0.1:3317/micro?useUncoide=true&chracterEncoding=utf-8&useSSL=false
|
||||
master:
|
||||
initial-size: 19
|
||||
username: root
|
||||
@@ -26,9 +26,6 @@ spring:
|
||||
max-active: 50
|
||||
min-idle: 10
|
||||
max-wait: 1000
|
||||
pool-prepared-statements: true
|
||||
test-on-borrow: true
|
||||
test-while-idle: true
|
||||
time-between-log-stats-millis: 10000
|
||||
min-evictable-idle-time-millis: 100000
|
||||
max-evictable-idle-time-millis: 200000
|
||||
|
||||
@@ -12,6 +12,57 @@ spring:
|
||||
enabled: true
|
||||
username: config
|
||||
password: server
|
||||
datasource:
|
||||
druid:
|
||||
username: root
|
||||
password: studyj2e
|
||||
url: jdbc:mysql://127.0.0.1:3317/micro?useUncoide=true&chracterEncoding=utf-8&useSSL=false
|
||||
master:
|
||||
initial-size: 19
|
||||
username: root
|
||||
password: studyj2e
|
||||
url: jdbc:mysql://127.0.0.1:3317/micro?useUncoide=true&chracterEncoding=utf-8&useSSL=false
|
||||
# 数据源共用基本配置
|
||||
driver-class-name: com.mysql.jdbc.Driver
|
||||
initial-size: 20
|
||||
max-active: 50
|
||||
min-idle: 10
|
||||
max-wait: 1000
|
||||
pool-prepared-statements: true
|
||||
test-on-borrow: true
|
||||
test-while-idle: true
|
||||
time-between-log-stats-millis: 10000
|
||||
min-evictable-idle-time-millis: 100000
|
||||
max-evictable-idle-time-millis: 200000
|
||||
default-auto-commit: true
|
||||
filters: stat,wall
|
||||
# url监控配置
|
||||
web-stat-filter:
|
||||
enabled: true
|
||||
url-pattern: /*
|
||||
exclusions: /static/*,/druid/*
|
||||
session-stat-enable: false
|
||||
stat-view-servlet:
|
||||
login-username: micro
|
||||
login-password: fast
|
||||
reset-enable: true
|
||||
allow: 127.0.0.1,172.17.0.1
|
||||
deny: 127.0.0.2
|
||||
enabled: true
|
||||
url-pattern: /druid/*
|
||||
# aop拦截监控
|
||||
aop-patterns: com.micro.*
|
||||
# statFilter配置
|
||||
filter:
|
||||
stat:
|
||||
connection-stack-trace-enable: true
|
||||
db-type: mysql
|
||||
enabled: true
|
||||
log-slow-sql: true
|
||||
merge-sql: true
|
||||
slow-sql-millis: 2000
|
||||
aop:
|
||||
proxy-target-class: true
|
||||
eureka:
|
||||
client:
|
||||
serviceUrl:
|
||||
|
||||
Reference in New Issue
Block a user