mirror of
https://codeup.aliyun.com/64f7d6b8ce01efaafef1e678/coal/coal.git
synced 2026-01-25 07:46:40 +08:00
完善
This commit is contained in:
@@ -37,6 +37,8 @@ services:
|
||||
- spring_data:/data
|
||||
ports:
|
||||
- "7456:7456"
|
||||
command:
|
||||
- --spring.profiles.active=master
|
||||
|
||||
networks:
|
||||
dn:
|
||||
|
||||
@@ -2,13 +2,12 @@ package cn.lihongjie.coal.config;
|
||||
|
||||
import com.alibaba.druid.pool.DruidDataSource;
|
||||
import com.p6spy.engine.spy.P6DataSource;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.context.annotation.Profile;
|
||||
import org.springframework.core.env.Environment;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
@@ -29,18 +28,13 @@ public class DruidConfig {
|
||||
|
||||
@Bean
|
||||
@Primary
|
||||
@Profile({"dev", "master"})
|
||||
public DataSource p6DataSource() {
|
||||
|
||||
DataSource dataSource = druidDataSource();
|
||||
|
||||
if (ArrayUtils.contains(environment.getActiveProfiles(), "dev")) {
|
||||
return new P6DataSource(druidDataSource());
|
||||
|
||||
|
||||
return new P6DataSource(dataSource);
|
||||
} else {
|
||||
return dataSource;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user