mirror of
https://github.com/drtrang/druid-spring-boot.git
synced 2026-10-28 03:33:52 +00:00
1.1.8 snapshot
This commit is contained in:
+1
-1
@@ -25,7 +25,7 @@ spring:
|
||||
password: 123456
|
||||
schema: classpath:import.sql
|
||||
druid:
|
||||
# spring.datasource.druid 前缀的配置将注入到 DruidDataSource2Support,作为公共参数
|
||||
# spring.datasource.druid 前缀的配置将注入到 AbstractDruidDataSource2,作为公共参数
|
||||
initial-size: 1
|
||||
min-idle: 1
|
||||
max-active: 10
|
||||
|
||||
+1
-10
@@ -1,9 +1,6 @@
|
||||
package com.github.trang.druid.example.mybatis;
|
||||
|
||||
import com.github.trang.druid.example.mybatis.mapper.CityMapper;
|
||||
import com.google.gson.Gson;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
@@ -22,15 +19,9 @@ public class DruidMybatisApplication implements CommandLineRunner {
|
||||
SpringApplication.run(DruidMybatisApplication.class, args);
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private CityMapper cityMapper;
|
||||
|
||||
@Override
|
||||
public void run(String... args) {
|
||||
Gson gson = new Gson();
|
||||
cityMapper.findAll().stream()
|
||||
.map(gson::toJson)
|
||||
.forEach(System.out::println);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+3
-2
@@ -17,10 +17,11 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
* @author trang
|
||||
*/
|
||||
@Slf4j
|
||||
@Getter
|
||||
public class DynamicDataSource extends AbstractRoutingDataSource {
|
||||
|
||||
private AtomicInteger count = new AtomicInteger();
|
||||
@Getter private Map<String, DataSource> targetDataSources;
|
||||
private final AtomicInteger count = new AtomicInteger();
|
||||
private final Map<String, DataSource> targetDataSources;
|
||||
|
||||
public DynamicDataSource(Map<String, DataSource> targetDataSources) {
|
||||
this.targetDataSources = targetDataSources;
|
||||
|
||||
+3
-40
@@ -1,5 +1,7 @@
|
||||
package com.github.trang.druid.example.mybatis.model;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
@@ -7,53 +9,14 @@ import java.io.Serializable;
|
||||
*
|
||||
* @author trang
|
||||
*/
|
||||
@Data
|
||||
public class City implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Long id;
|
||||
|
||||
private String name;
|
||||
|
||||
private String state;
|
||||
|
||||
private String country;
|
||||
|
||||
public Long getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getState() {
|
||||
return this.state;
|
||||
}
|
||||
|
||||
public void setState(String state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public String getCountry() {
|
||||
return this.country;
|
||||
}
|
||||
|
||||
public void setCountry(String country) {
|
||||
this.country = country;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getId() + "," + getName() + "," + getState() + "," + getCountry();
|
||||
}
|
||||
|
||||
}
|
||||
+20
-34
@@ -1,13 +1,12 @@
|
||||
debug: false
|
||||
|
||||
logging:
|
||||
level:
|
||||
root: info
|
||||
org.springframework: info
|
||||
org.springframework.jdbc: debug
|
||||
org.mybatis: debug
|
||||
com.alibaba.druid: debug
|
||||
com.github.trang: debug
|
||||
org.springframework.jdbc: info
|
||||
org.mybatis: info
|
||||
com.alibaba.druid: info
|
||||
com.github.trang: info
|
||||
executableSql: debug
|
||||
|
||||
spring:
|
||||
application:
|
||||
@@ -16,29 +15,19 @@ spring:
|
||||
# 默认环境为 default,多数据源演示请改为 dynamic
|
||||
# active: dynamic
|
||||
active: default
|
||||
output:
|
||||
ansi:
|
||||
enabled: detect
|
||||
h2:
|
||||
console:
|
||||
enabled: true
|
||||
settings:
|
||||
trace: true
|
||||
datasource:
|
||||
url: jdbc:h2:mem:example
|
||||
username: root
|
||||
password: 123456
|
||||
schema: classpath:import.sql
|
||||
druid:
|
||||
# spring.datasource.druid 前缀的配置将注入到 DruidDataSource2Support,作为公共参数
|
||||
initial-size: 1
|
||||
min-idle: 1
|
||||
max-active: 10
|
||||
max-wait: 30000
|
||||
time-between-eviction-runs-millis: 60000
|
||||
min-evictable-idle-time-millis: 1800000
|
||||
max-evictable-idle-time-millis: 25200000
|
||||
query-timeout: 10
|
||||
validation-query: SELECT 1
|
||||
test-while-idle: true
|
||||
test-on-borrow: false
|
||||
test-on-return: false
|
||||
pool-prepared-statements: true
|
||||
max-open-prepared-statements: 20
|
||||
use-global-data-source-stat: true
|
||||
# 默认开启,当前已开启
|
||||
stat:
|
||||
@@ -47,11 +36,9 @@ spring:
|
||||
# 默认关闭,需手动开启,当前已开启
|
||||
slf4j:
|
||||
enabled: true
|
||||
data-source-log-enabled: false
|
||||
connection-log-enabled: false
|
||||
statement-sql-format-option:
|
||||
upp-case: true
|
||||
pretty-format: false
|
||||
statement-executable-sql-log-enable: true
|
||||
statement-log-enabled: false
|
||||
result-set-log-enabled: false
|
||||
# 默认关闭,需手动开启,当前已开启
|
||||
wall:
|
||||
@@ -72,13 +59,11 @@ spring:
|
||||
# 默认关闭,需手动开启,当前已关闭
|
||||
stat-view-servlet:
|
||||
enabled: false
|
||||
h2:
|
||||
console:
|
||||
enabled: true
|
||||
settings:
|
||||
trace: true
|
||||
transaction:
|
||||
rollback-on-commit-failure: true
|
||||
mvc:
|
||||
servlet:
|
||||
load-on-startup: 1
|
||||
aop:
|
||||
auto: true
|
||||
proxy-target-class: true
|
||||
@@ -102,23 +87,25 @@ spring:
|
||||
parser:
|
||||
allow_unquoted_control_chars: true
|
||||
allow_single_quotes: true
|
||||
|
||||
mybatis:
|
||||
type-aliases-package: com.github.trang.druid.example.mybatis.model
|
||||
configuration:
|
||||
cache-enabled: false
|
||||
map-underscore-to-camel-case: true
|
||||
log-impl: org.apache.ibatis.logging.slf4j.Slf4jImpl
|
||||
log-prefix: executableSql.
|
||||
|
||||
---
|
||||
|
||||
debug: true
|
||||
debug: false
|
||||
|
||||
spring:
|
||||
profiles: default
|
||||
|
||||
---
|
||||
|
||||
debug: true
|
||||
debug: false
|
||||
|
||||
spring:
|
||||
profiles: dynamic
|
||||
@@ -128,7 +115,6 @@ spring:
|
||||
# 循环依赖,所以需要手动排除 `org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration`
|
||||
- org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration
|
||||
datasource:
|
||||
schema: classpath:import.sql
|
||||
druid:
|
||||
# 继承 spring.datasource.druid 前缀的配置,同时可以自定义配置,若名称相同则覆盖父配置
|
||||
data-sources:
|
||||
|
||||
+68
-60
@@ -9,99 +9,107 @@ spring:
|
||||
password: Biyu5YzU+6sxDRbmWEa3B2uUcImzDo0BuXjTlL505+/pTb+/0Oqd3ou1R6J8+9Fy3CYrM18nBDqf6wAaPgUGOg==
|
||||
schema: classpath:import.sql
|
||||
druid:
|
||||
initial-size: 1
|
||||
min-idle: 1
|
||||
max-active: 10
|
||||
max-wait: 30000
|
||||
time-between-eviction-runs-millis: 60000
|
||||
min-evictable-idle-time-millis: 1800000
|
||||
max-evictable-idle-time-millis: 25200000
|
||||
initial-size: 0
|
||||
max-active: 8
|
||||
min-idle: 0
|
||||
max-wait: -1
|
||||
not-full-timeout-retry-count: 0
|
||||
validation-query: SELECT 1
|
||||
validation-query-timeout: -1
|
||||
test-while-idle: true
|
||||
test-on-borrow: false
|
||||
test-on-return: false
|
||||
pool-prepared-statements: true
|
||||
max-open-prepared-statements: 20
|
||||
use-global-data-source-stat: true
|
||||
time-between-eviction-runs-millis: 60000
|
||||
time-between-connect-error-millis: 500
|
||||
min-evictable-idle-time-millis: 1800000
|
||||
max-evictable-idle-time-millis: 25200000
|
||||
phy-timeout-millis: -1
|
||||
pool-prepared-statements: false
|
||||
share-prepared-statements: false
|
||||
max-pool-prepared-statement-per-connection-size: 10
|
||||
use-global-data-source-stat: false
|
||||
stat:
|
||||
## 是否开启 StatFilter,默认 true,可以不写(https://github.com/alibaba/druid/wiki/%E9%85%8D%E7%BD%AE_StatFilter)
|
||||
enabled: true
|
||||
## 数据库类型
|
||||
db-type: h2
|
||||
db-type:
|
||||
## 是否开启慢查询统计
|
||||
log-slow-sql: true
|
||||
log-slow-sql: false
|
||||
## 慢查询的定义
|
||||
slow-sql-millis: 1000
|
||||
slow-sql-millis: 3000
|
||||
## 是否开启合并参数化 SQL
|
||||
merge-sql: true
|
||||
merge-sql: false
|
||||
## 是否开启连接的堆栈信息
|
||||
connection-stack-trace-enable: false
|
||||
slf4j:
|
||||
## 是否开启 StatFilter,默认 false(https://github.com/alibaba/druid/wiki/%E9%85%8D%E7%BD%AE_LogFilter)
|
||||
enabled: true
|
||||
## datasource log 的总开关
|
||||
## 无调用者,Slf4jLogFilter#isDataSourceLogEnabled
|
||||
## datasource log 的总开关,前置条件:druid.sql.DataSource 的日志级别为 debug
|
||||
## 无调用者
|
||||
data-source-log-enabled: true
|
||||
## connection log 的总开关
|
||||
connection-log-enabled: false
|
||||
### 无调用者,LogFilter#isConnectionConnectBeforeLogEnabled
|
||||
connection-connect-before-log-enabled: false
|
||||
## connection log 的总开关,前置条件:druid.sql.Connection 的日志级别为 debug
|
||||
connection-log-enabled: true
|
||||
## connection error log 的总开关,前置条件:druid.sql.Connection 的日志级别为 debug
|
||||
## 无调用者
|
||||
connection-log-error-enabled: true
|
||||
### 无调用者
|
||||
connection-connect-before-log-enabled: true
|
||||
### {conn-410001} connected
|
||||
### {conn-410001} pool-connect
|
||||
connection-connect-after-log-enabled: false
|
||||
### 无调用者,LogFilter#isConnectionCommitAfterLogEnabled
|
||||
connection-commit-after-log-enabled: false
|
||||
### 无调用者,LogFilter#isConnectionRollbackAfterLogEnabled
|
||||
connection-rollback-after-log-enabled: false
|
||||
connection-connect-after-log-enabled: true
|
||||
### {conn-410001} pool-recycle
|
||||
connection-close-after-log-enabled: false
|
||||
## statement log 的总开关
|
||||
### {conn-410001} closed
|
||||
connection-close-after-log-enabled: true
|
||||
### 无调用者
|
||||
connection-commit-after-log-enabled: true
|
||||
### 无调用者
|
||||
connection-rollback-after-log-enabled: true
|
||||
## statement log 的总开关,前置条件:druid.sql.Statement 的日志级别为 debug
|
||||
statement-log-enabled: true
|
||||
## statement sql 输出选项,可以开启多个
|
||||
statement-sql-format-option:
|
||||
### 关键字大写
|
||||
upp-case: true
|
||||
upp-case: false
|
||||
### 表名不敏感
|
||||
desensitize: false
|
||||
### 格式化
|
||||
pretty-format: false
|
||||
pretty-format: true
|
||||
### 参数化,column=?
|
||||
parameterized: false
|
||||
## statement sql 格式化选项
|
||||
statement-sql-pretty-format: false
|
||||
### {conn-410001, pstmt-420002} created.
|
||||
statement-create-after-log-enabled: false
|
||||
### 无调用者,LogFilter#isStatementPrepareAfterLogEnabled
|
||||
statement-prepare-after-log-enabled: false
|
||||
### 无调用者,LogFilter#isStatementPrepareCallAfterLogEnabled
|
||||
statement-prepare-call-after-log-enabled: false
|
||||
### {conn-410001, pstmt-420002} executed.
|
||||
statement-execute-after-log-enabled: false
|
||||
### 无调用者,LogFilter#isStatementExecuteQueryAfterLogEnabled
|
||||
statement-execute-query-after-log-enabled: false
|
||||
### 无调用者,LogFilter#isStatementExecuteUpdateAfterLogEnabled
|
||||
statement-execute-update-after-log-enabled: false
|
||||
### 无调用者,LogFilter#isStatementExecuteBatchAfterLogEnabled
|
||||
statement-execute-batch-after-log-enabled: false
|
||||
### {conn-410001, pstmt-420002} executed. $sql
|
||||
statement-sql-pretty-format: true
|
||||
### {conn-410001, pstmt-420002} created. $sql
|
||||
statement-create-after-log-enabled: true
|
||||
### {conn-410001, pstmt-420002} Parameters :[]
|
||||
### {conn-410001, pstmt-420002} Types :[]
|
||||
statement-parameter-set-log-enabled: true
|
||||
### {conn-410001, pstmt-420002} executed. $executable-sql
|
||||
statement-executable-sql-log-enable: false
|
||||
### {conn-410001, pstmt-420002} executed. 2.073044 millis. $sql
|
||||
statement-execute-after-log-enabled: true
|
||||
### {conn-410001, pstmt-420002} closed
|
||||
statement-close-after-log-enabled: false
|
||||
statement-close-after-log-enabled: true
|
||||
### 无调用者,LogFilter#isStatementPrepareAfterLogEnabled
|
||||
statement-prepare-after-log-enabled: true
|
||||
### 无调用者,LogFilter#isStatementPrepareCallAfterLogEnabled
|
||||
statement-prepare-call-after-log-enabled: true
|
||||
### 无调用者,LogFilter#isStatementExecuteQueryAfterLogEnabled
|
||||
statement-execute-query-after-log-enabled: true
|
||||
### 无调用者,LogFilter#isStatementExecuteUpdateAfterLogEnabled
|
||||
statement-execute-update-after-log-enabled: true
|
||||
### 无调用者,LogFilter#isStatementExecuteBatchAfterLogEnabled
|
||||
statement-execute-batch-after-log-enabled: true
|
||||
### {conn-410001, pstmt-420002} clearParameters.
|
||||
statement-parameter-clear-log-enable: false
|
||||
### {conn-410001, pstmt-420002} Parameters :
|
||||
### {conn-410001, pstmt-420002} Types :
|
||||
statement-parameter-set-log-enabled: false
|
||||
## result-set log 的总开关
|
||||
result-set-log-enabled: false
|
||||
statement-parameter-clear-log-enable: true
|
||||
## result-set log 的总开关,前置条件:druid.sql.ResultSet 的日志级别为 debug
|
||||
result-set-log-enabled: true
|
||||
### {conn-410001, pstmt-420000, rs-450000} open
|
||||
### {conn-410001, pstmt-420000, rs-450000} Header:
|
||||
result-set-open-after-log-enabled: false
|
||||
### {conn-410001, pstmt-420000, rs-450000} Result:
|
||||
result-set-next-after-log-enabled: false
|
||||
### {conn-410001, pstmt-420000, rs-450000} Header: []
|
||||
result-set-open-after-log-enabled: true
|
||||
### {conn-410001, pstmt-420000, rs-450000} Result: []
|
||||
result-set-next-after-log-enabled: true
|
||||
### {conn-410001, pstmt-420000, rs-450000} closed
|
||||
result-set-close-after-log-enabled: false
|
||||
## connection error log 的总开关
|
||||
## 无调用者,Slf4jLogFilter#isConnectionLogErrorEnabled
|
||||
connection-log-error-enabled: true
|
||||
result-set-close-after-log-enabled: true
|
||||
## statement error log 的总开关
|
||||
## {conn-410001, pstmt-420002} executed error.
|
||||
statement-log-error-enabled: true
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
import static com.github.trang.druid.autoconfigure.properties.DruidDataSourceProperties.*;
|
||||
import static com.github.trang.druid.autoconfigure.properties.DruidDataSourceProperties.DruidConstants.*;
|
||||
|
||||
/**
|
||||
* Druid 连接池的自动配置
|
||||
|
||||
+2
-5
@@ -15,8 +15,7 @@ import org.springframework.util.StringUtils;
|
||||
|
||||
import javax.servlet.Servlet;
|
||||
|
||||
import static com.github.trang.druid.autoconfigure.properties.DruidDataSourceProperties.DRUID_STAT_VIEW_SERVLET_PREFIX;
|
||||
|
||||
import static com.github.trang.druid.autoconfigure.properties.DruidDataSourceProperties.DruidConstants.*;
|
||||
|
||||
/**
|
||||
* Druid Servlet 配置
|
||||
@@ -40,9 +39,7 @@ public class DruidServletConfiguration {
|
||||
public ServletRegistrationBean servletRegistrationBean(DruidDataSourceProperties druidDataSourceProperties) {
|
||||
log.debug("druid stat-view-servlet init...");
|
||||
DruidStatViewServletProperties properties = druidDataSourceProperties.getStatViewServlet();
|
||||
ServletRegistrationBean registration = new ServletRegistrationBean();
|
||||
StatViewServlet statViewServlet = new StatViewServlet();
|
||||
registration.setServlet(statViewServlet);
|
||||
ServletRegistrationBean<StatViewServlet> registration = new ServletRegistrationBean<>(new StatViewServlet());
|
||||
registration.addUrlMappings(properties.getUrlMappings());
|
||||
if (!StringUtils.isEmpty(properties.getLoginUsername())) {
|
||||
registration.addInitParameter("loginUsername", properties.getLoginUsername());
|
||||
|
||||
+2
-5
@@ -20,8 +20,7 @@ import org.springframework.util.StringUtils;
|
||||
|
||||
import javax.servlet.Filter;
|
||||
|
||||
import static com.github.trang.druid.autoconfigure.properties.DruidDataSourceProperties.DRUID_AOP_STAT_PREFIX;
|
||||
import static com.github.trang.druid.autoconfigure.properties.DruidDataSourceProperties.DRUID_WEB_STAT_PREFIX;
|
||||
import static com.github.trang.druid.autoconfigure.properties.DruidDataSourceProperties.DruidConstants.*;
|
||||
|
||||
/**
|
||||
* Druid 监控配置
|
||||
@@ -78,9 +77,7 @@ public class DruidStatConfiguration {
|
||||
public FilterRegistrationBean filterRegistrationBean(DruidDataSourceProperties druidDataSourceProperties) {
|
||||
log.debug("druid web-stat-filter init...");
|
||||
DruidWebStatProperties properties = druidDataSourceProperties.getWebStat();
|
||||
FilterRegistrationBean registration = new FilterRegistrationBean();
|
||||
WebStatFilter filter = new WebStatFilter();
|
||||
registration.setFilter(filter);
|
||||
FilterRegistrationBean<WebStatFilter> registration = new FilterRegistrationBean<>(new WebStatFilter());
|
||||
registration.addUrlPatterns(properties.getUrlPatterns());
|
||||
registration.addInitParameter("exclusions", properties.getExclusions());
|
||||
registration.addInitParameter("sessionStatEnable", Boolean.toString(properties.isSessionStatEnable()));
|
||||
|
||||
+9
-7
@@ -6,6 +6,7 @@ import com.alibaba.druid.filter.config.ConfigFilter;
|
||||
import com.alibaba.druid.pool.DruidDataSource;
|
||||
import com.github.trang.druid.autoconfigure.properties.DruidDataSourceProperties;
|
||||
import com.github.trang.druid.autoconfigure.properties.DruidDataSourceProperties.DruidConfigFilterProperties;
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
@@ -16,7 +17,7 @@ import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
|
||||
import static com.github.trang.druid.autoconfigure.properties.DruidDataSourceProperties.DRUID_DATA_SOURCE_PREFIX;
|
||||
import static com.github.trang.druid.autoconfigure.properties.DruidDataSourceProperties.DruidConstants.DRUID_DATA_SOURCE_PREFIX;
|
||||
|
||||
/**
|
||||
* Druid 多数据源支持,会自动注入 'spring.datasource' 和 'spring.datasource.druid' 配置
|
||||
@@ -24,14 +25,16 @@ import static com.github.trang.druid.autoconfigure.properties.DruidDataSourcePro
|
||||
* @author trang
|
||||
*/
|
||||
@ConfigurationProperties(prefix = DRUID_DATA_SOURCE_PREFIX)
|
||||
public abstract class DruidDataSource2Support extends DruidDataSource {
|
||||
public abstract class AbstractDruidDataSource2 extends DruidDataSource {
|
||||
|
||||
private static final long serialVersionUID = -5155027912840793367L;
|
||||
|
||||
@Autowired
|
||||
private DataSourceProperties dataSourceProperties;
|
||||
@Autowired
|
||||
private DruidDataSourceProperties druidDataSourceProperties;
|
||||
@Autowired(required = false)
|
||||
private List<FilterAdapter> druidFilters;
|
||||
@Autowired
|
||||
private ObjectProvider<List<FilterAdapter>> druidFilters;
|
||||
|
||||
@PostConstruct
|
||||
public void initDruidParentProperties() {
|
||||
@@ -73,13 +76,12 @@ public abstract class DruidDataSource2Support extends DruidDataSource {
|
||||
|
||||
private void initFilters() {
|
||||
List<Filter> proxyFilters = super.getProxyFilters();
|
||||
Optional.ofNullable(druidFilters)
|
||||
Optional.of(druidFilters.getIfAvailable())
|
||||
.filter(filters -> !filters.isEmpty())
|
||||
.ifPresent(filters -> filters.stream()
|
||||
.filter(Objects::nonNull)
|
||||
.filter(filter -> !proxyFilters.contains(filter))
|
||||
.forEach(proxyFilters::add)
|
||||
);
|
||||
.forEach(proxyFilters::add));
|
||||
}
|
||||
|
||||
}
|
||||
+4
-2
@@ -1,10 +1,12 @@
|
||||
package com.github.trang.druid.autoconfigure.datasource;
|
||||
|
||||
/**
|
||||
* Druid 数据源,会继承 DruidDataSource2Support 的配置,并注入 'spring.datasource.druid.data-source.${name}' 的配置
|
||||
* Druid 数据源,会继承 AbstractDruidDataSource2 的配置,并注入 'spring.datasource.druid.data-source.${name}' 的配置
|
||||
*
|
||||
* @author trang
|
||||
*/
|
||||
public class DruidDataSource2 extends DruidDataSource2Support {
|
||||
public class DruidDataSource2 extends AbstractDruidDataSource2 {
|
||||
|
||||
private static final long serialVersionUID = 4980333179163868927L;
|
||||
|
||||
}
|
||||
+19
-14
@@ -9,7 +9,7 @@ import org.springframework.boot.context.properties.NestedConfigurationProperty;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.github.trang.druid.autoconfigure.properties.DruidDataSourceProperties.DRUID_DATA_SOURCE_PREFIX;
|
||||
import static com.github.trang.druid.autoconfigure.properties.DruidDataSourceProperties.DruidConstants.*;
|
||||
|
||||
/**
|
||||
* Druid 自定义配置
|
||||
@@ -20,33 +20,38 @@ import static com.github.trang.druid.autoconfigure.properties.DruidDataSourcePro
|
||||
@Getter @Setter
|
||||
public class DruidDataSourceProperties {
|
||||
|
||||
public static final String DRUID_DATA_SOURCE_PREFIX = "spring.datasource.druid";
|
||||
public static final String DRUID_STAT_FILTER_PREFIX = "spring.datasource.druid.stat";
|
||||
public static final String DRUID_WALL_FILTER_PREFIX = "spring.datasource.druid.wall";
|
||||
public static final String DRUID_WALL_CONFIG_PREFIX = "spring.datasource.druid.wall.config";
|
||||
public static final String DRUID_SLF4J_FILTER_PREFIX = "spring.datasource.druid.slf4j";
|
||||
public static final String DRUID_LOG4J_FILTER_PREFIX = "spring.datasource.druid.log4j";
|
||||
public static final String DRUID_LOG4J2_FILTER_PREFIX = "spring.datasource.druid.log4j2";
|
||||
public static final String DRUID_COMMONS_LOG_FILTER_PREFIX = "spring.datasource.druid.commons-log";
|
||||
public static final String DRUID_CONFIG_FILTER_PREFIX = "spring.datasource.druid.config";
|
||||
public static final String DRUID_STAT_VIEW_SERVLET_PREFIX = "spring.datasource.druid.stat-view-servlet";
|
||||
public static final String DRUID_WEB_STAT_PREFIX = "spring.datasource.druid.web-stat";
|
||||
public static final String DRUID_AOP_STAT_PREFIX = "spring.datasource.druid.aop-stat";
|
||||
Map<String, DruidDataSource> dataSources = new HashMap<>(16);
|
||||
|
||||
/** druid config-filter 配置 */
|
||||
@NestedConfigurationProperty
|
||||
DruidConfigFilterProperties config = new DruidConfigFilterProperties();
|
||||
|
||||
/** druid stat-view-servlet 配置 */
|
||||
@NestedConfigurationProperty
|
||||
DruidStatViewServletProperties statViewServlet = new DruidStatViewServletProperties();
|
||||
|
||||
/** druid web-stat 配置 */
|
||||
@NestedConfigurationProperty
|
||||
DruidWebStatProperties webStat = new DruidWebStatProperties();
|
||||
|
||||
/** druid aop-stat 配置 */
|
||||
@NestedConfigurationProperty
|
||||
DruidAopStatProperties aopStat = new DruidAopStatProperties();
|
||||
|
||||
Map<String, DruidDataSource> dataSources = new HashMap<>(16);
|
||||
public static class DruidConstants {
|
||||
public static final String DRUID_DATA_SOURCE_PREFIX = "spring.datasource.druid";
|
||||
public static final String DRUID_STAT_FILTER_PREFIX = "spring.datasource.druid.stat";
|
||||
public static final String DRUID_WALL_FILTER_PREFIX = "spring.datasource.druid.wall";
|
||||
public static final String DRUID_WALL_CONFIG_PREFIX = "spring.datasource.druid.wall.config";
|
||||
public static final String DRUID_SLF4J_FILTER_PREFIX = "spring.datasource.druid.slf4j";
|
||||
public static final String DRUID_LOG4J_FILTER_PREFIX = "spring.datasource.druid.log4j";
|
||||
public static final String DRUID_LOG4J2_FILTER_PREFIX = "spring.datasource.druid.log4j2";
|
||||
public static final String DRUID_COMMONS_LOG_FILTER_PREFIX = "spring.datasource.druid.commons-log";
|
||||
public static final String DRUID_CONFIG_FILTER_PREFIX = "spring.datasource.druid.config";
|
||||
public static final String DRUID_STAT_VIEW_SERVLET_PREFIX = "spring.datasource.druid.stat-view-servlet";
|
||||
public static final String DRUID_WEB_STAT_PREFIX = "spring.datasource.druid.web-stat";
|
||||
public static final String DRUID_AOP_STAT_PREFIX = "spring.datasource.druid.aop-stat";
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
|
||||
Reference in New Issue
Block a user