init
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
package com.cool.store;
|
||||
|
||||
import com.zaxxer.hikari.HikariDataSource;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.boot.web.servlet.ServletComponentScan;
|
||||
import org.springframework.cache.annotation.EnableCaching;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.scheduling.annotation.EnableAsync;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
/**
|
||||
* @author zhangchenbiao
|
||||
* @FileName: PartnerBWebApplication
|
||||
* @Description: B端web层
|
||||
* @date 2023-05-17 11:28
|
||||
*/
|
||||
@SpringBootApplication
|
||||
@MapperScan("com.cool.store.mapper")
|
||||
@EnableAsync
|
||||
@EnableCaching
|
||||
@ServletComponentScan
|
||||
public class PartnerCWebApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(PartnerCWebApplication.class, args);
|
||||
}
|
||||
|
||||
@Bean
|
||||
@Primary
|
||||
@ConfigurationProperties("default.datasource")
|
||||
public DataSourceProperties defaultDataSourceProperties() {
|
||||
return new DataSourceProperties();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConfigurationProperties("spring.datasource.hikari")
|
||||
public DataSource defaultDataSource() {
|
||||
DataSource defaultDataSource = defaultDataSourceProperties().initializeDataSourceBuilder().type(HikariDataSource.class).build();
|
||||
return defaultDataSource;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.cool.store.config;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.cool.store.config.datasource.DynamicDataSourceServiceImpl;
|
||||
import com.cool.store.model.dto.DatasourceInfoDTO;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zhangchenbiao
|
||||
* @FileName: CommonBeanConfig
|
||||
* @Description:
|
||||
* @date 2022-01-25 18:41
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class CommonBeanConfig {
|
||||
|
||||
@Autowired
|
||||
private DynamicDataSourceServiceImpl dynamicDataSourceServiceImpl;
|
||||
|
||||
|
||||
@PostConstruct
|
||||
public void loadDataSource(){
|
||||
List<DatasourceInfoDTO> dbServerList = dynamicDataSourceServiceImpl.getDbNodes();
|
||||
if (CollectionUtils.isEmpty(dbServerList)) {
|
||||
return;
|
||||
}
|
||||
dbServerList.forEach(node -> {
|
||||
dynamicDataSourceServiceImpl.createDataSource(node);
|
||||
});
|
||||
log.info("数据源加载完毕:{}", JSONObject.toJSONString(dbServerList));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
package com.cool.store.config.datasource;
|
||||
|
||||
import com.cool.store.model.constants.CommonConstants;
|
||||
import com.cool.store.service.context.DataSourceContext;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.jdbc.datasource.AbstractDataSource;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Map;
|
||||
|
||||
@Primary
|
||||
@Component
|
||||
public class DynamicDataSource extends AbstractDataSource {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(DynamicDataSource.class);
|
||||
|
||||
@Autowired
|
||||
private DataSource defaultDataSource;
|
||||
|
||||
@Autowired
|
||||
private DynamicDataSourceServiceImpl dynamicDataSourceService;
|
||||
|
||||
@Override
|
||||
public Connection getConnection() throws SQLException {
|
||||
String currentDbName = getCurrentDbName();
|
||||
if(CommonConstants.DEFAULT_DB.equals(currentDbName)){
|
||||
Connection connection = defaultDataSource.getConnection();
|
||||
connection.setCatalog(currentDbName);
|
||||
return connection;
|
||||
}
|
||||
Connection connection = this.determineTargetDataSource().getConnection();
|
||||
connection.setCatalog(currentDbName);
|
||||
return connection;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Connection getConnection(String username, String password) throws SQLException {
|
||||
String currentDbName = getCurrentDbName();
|
||||
if(CommonConstants.DEFAULT_DB.equals(currentDbName)){
|
||||
Connection connection = defaultDataSource.getConnection();
|
||||
connection.setCatalog(currentDbName);
|
||||
return connection;
|
||||
}
|
||||
Connection connection = this.determineTargetDataSource().getConnection(username, password);
|
||||
connection.setCatalog(getCurrentDbName());
|
||||
return connection;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T unwrap(Class<T> iface) throws SQLException {
|
||||
return iface.isInstance(this) ? (T) this : this.determineTargetDataSource().unwrap(iface);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWrapperFor(Class<?> iface) throws SQLException {
|
||||
return iface.isInstance(this) || this.determineTargetDataSource().isWrapperFor(iface);
|
||||
}
|
||||
|
||||
|
||||
protected DataSource determineTargetDataSource() {
|
||||
DataSource dataSource = null;
|
||||
Map<String, DataSource> resolvedDataSources = dynamicDataSourceService.getResolvedDataSources();
|
||||
if (resolvedDataSources != null) {
|
||||
String lookupKey = getDbServerByDbName();
|
||||
if (StringUtils.isNotBlank(lookupKey)) {
|
||||
dataSource = resolvedDataSources.get(lookupKey);
|
||||
}
|
||||
}
|
||||
if (dataSource == null) {
|
||||
dataSource = defaultDataSource;
|
||||
}
|
||||
return dataSource;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过dbName获取dbServer
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
protected String getDbServerByDbName() {
|
||||
String dbName = getCurrentDbName();
|
||||
return dynamicDataSourceService.getDbServerByDbName(dbName);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询当前线程上下文对应的库名
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
protected String getCurrentDbName() {
|
||||
String dbName = DataSourceContext.getDataSourceType();
|
||||
if (StringUtils.isBlank(dbName)) {
|
||||
dbName = CommonConstants.DEFAULT_DB;
|
||||
}
|
||||
return dbName;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
package com.cool.store.config.datasource;
|
||||
|
||||
import com.cool.store.model.constants.CommonConstants;
|
||||
import com.cool.store.model.dto.DatasourceInfoDTO;
|
||||
import com.cool.store.model.entity.EnterpriseConfigDO;
|
||||
import com.cool.store.model.utils.RedisUtilPool;
|
||||
import com.cool.store.service.EnterpriseConfigService;
|
||||
import com.cool.store.service.context.DataSourceContext;
|
||||
import com.github.pagehelper.Page;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.zaxxer.hikari.HikariConfig;
|
||||
import com.zaxxer.hikari.HikariDataSource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* @ClassName DynamicDataSourceServiceImpl
|
||||
* @Description 用一句话描述什么
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class DynamicDataSourceServiceImpl {
|
||||
|
||||
private static int defaultMaxPoolSize = 150;
|
||||
|
||||
private static String dbUrl = "jdbc:mysql://{0}:{1}/coolcollege_intelligent_config?useSSL=false&useUnicode=true&characterEncoding=utf8&allowMultiQueries=true&autoReconnect=true";
|
||||
|
||||
@Autowired
|
||||
private RedisUtilPool redisUtilPool;
|
||||
|
||||
@Autowired
|
||||
private MyHikariConfig myHikariConfig;
|
||||
|
||||
@Autowired
|
||||
private EnterpriseConfigService enterpriseConfigService;
|
||||
|
||||
/**
|
||||
* 数据库实例和数据源的映射
|
||||
*/
|
||||
private ConcurrentHashMap<String, DataSource> resolvedDataSources = new ConcurrentHashMap();
|
||||
|
||||
/**
|
||||
* dbName 和 serverUrl的映射
|
||||
*/
|
||||
private ConcurrentHashMap<String, String> dbNameUrlServerMap = new ConcurrentHashMap();
|
||||
|
||||
/**
|
||||
* 查询所有的企业数据库实例节点配置信息
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public List<DatasourceInfoDTO> getDbNodes() {
|
||||
List<EnterpriseConfigDO> configList = enterpriseConfigService.getDistinctDbServer();
|
||||
return DatasourceInfoDTO.convertList(configList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据dbName查询dbServer
|
||||
*
|
||||
* @param dbName
|
||||
* @return
|
||||
*/
|
||||
public String getDbServerByDbName(String dbName) {
|
||||
if(CommonConstants.DEFAULT_DB.equals(dbName)){
|
||||
return null;
|
||||
}
|
||||
String dbServerUrl = dbNameUrlServerMap.get(dbName);
|
||||
if(StringUtils.isBlank(dbServerUrl)){
|
||||
Page<Object> localPage = PageHelper.getLocalPage();
|
||||
if(Objects.nonNull(localPage)){
|
||||
PageHelper.clearPage();
|
||||
}
|
||||
String currentDbName = DataSourceContext.getDataSourceType();
|
||||
EnterpriseConfigDO config = enterpriseConfigService.getDbInfoByDbName(dbName);
|
||||
dbServerUrl = config.getDbServer();
|
||||
if(StringUtils.isNotBlank(currentDbName)){
|
||||
DataSourceContext.setDataSourceType(currentDbName);
|
||||
}
|
||||
if(Objects.nonNull(localPage)){
|
||||
//上下文中的东西及时还回去
|
||||
PageHelper.startPage(localPage.getPageNum(), localPage.getPageSize());
|
||||
}
|
||||
dbNameUrlServerMap.put(dbName, dbServerUrl);
|
||||
}
|
||||
return dbServerUrl;
|
||||
}
|
||||
|
||||
public void createDataSource(DatasourceInfoDTO datasource) {
|
||||
DataSource dataSource = buildDataSourceByConfig(datasource);
|
||||
if (dataSource != null) {
|
||||
this.resolvedDataSources.putIfAbsent(datasource.getDbServer(), dataSource);
|
||||
}
|
||||
}
|
||||
|
||||
public Map<String, DataSource> getResolvedDataSources() {
|
||||
return resolvedDataSources;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* build datasource
|
||||
* @param dbServerUrl
|
||||
* @return
|
||||
*/
|
||||
private DataSource buildDataSourceByConfig(DatasourceInfoDTO datasource) {
|
||||
HikariConfig hikariConfig = new HikariConfig();
|
||||
String url = MessageFormat.format(dbUrl, datasource.getDbServer(), String.valueOf(datasource.getDbPort()));
|
||||
hikariConfig.setDriverClassName(myHikariConfig.getDriverClassName());
|
||||
hikariConfig.setMinimumIdle(myHikariConfig.getMinimumIdle());
|
||||
hikariConfig.setMaximumPoolSize(myHikariConfig.getMaximumPoolSize());
|
||||
hikariConfig.setMaxLifetime(myHikariConfig.getMaxLifetime());
|
||||
hikariConfig.setConnectionTimeout(myHikariConfig.getConnectionTimeout());
|
||||
hikariConfig.setIdleTimeout(myHikariConfig.getIdleTimeout());
|
||||
hikariConfig.setJdbcUrl(url);
|
||||
hikariConfig.setUsername(datasource.getDbUser());
|
||||
hikariConfig.setPassword(datasource.getDbPwd());
|
||||
hikariConfig.setMaximumPoolSize(defaultMaxPoolSize);
|
||||
String poolName = "HikariCP_" + datasource.getDbServer();
|
||||
hikariConfig.setPoolName(poolName);
|
||||
HikariDataSource hikariDataSource = new HikariDataSource(hikariConfig);
|
||||
log.info("{} dataSource is {}, maxPoolSize={}", poolName, hikariDataSource, hikariDataSource.getMaximumPoolSize());
|
||||
return hikariDataSource;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.cool.store.config.datasource;
|
||||
|
||||
import com.zaxxer.hikari.HikariConfig;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@ConfigurationProperties("spring.datasource.hikari")
|
||||
public class MyHikariConfig extends HikariConfig {
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
#mysql config
|
||||
default.datasource.url=jdbc:mysql://dingpushcoolcollege.mysql.rds.aliyuncs.com:3306/coolcollege_intelligent_config?useSSL=false&useUnicode=true&characterEncoding=utf8&allowMultiQueries=true&autoReconnect=true&serverTimezone=Asia/Shanghai
|
||||
default.datasource.username=coolstore
|
||||
default.datasource.password=CSCErYcXniNYm7bT
|
||||
|
||||
#redis
|
||||
spring.redis.host=tstore-coolcollege.redis.rds.aliyuncs.com
|
||||
spring.redis.port=6379
|
||||
spring.redis.password=Cx111111
|
||||
spring.redis.database=0
|
||||
spring.redis.timeout=2000ms
|
||||
spring.redis.lettuce.pool.max-wait=100ms
|
||||
spring.redis.lettuce.pool.max-active=1024
|
||||
spring.redis.lettuce.pool.max-idle=200
|
||||
spring.redis.lettuce.pool.min-idle=0
|
||||
spring.redis.lettuce.shutdown-timeout=100ms
|
||||
redis.host.uri=http://userInfo:Cx111111@tstore-coolcollege.redis.rds.aliyuncs.com:6379/0
|
||||
redis.isv.host.uri=http://userInfo:Cx111111@tstore-coolcollege.redis.rds.aliyuncs.com:6379/2
|
||||
|
||||
#pagehelper
|
||||
pagehelper.helper-dialect=mysql
|
||||
pagehelper.reasonable=false
|
||||
pagehelper.returnPageInfo=check
|
||||
pagehelper.support-methods-arguments=false
|
||||
pagehelper.params=count=countSql
|
||||
pagehelper.page-size-zero=true
|
||||
|
||||
spring.mvc.async.request-timeout=60000
|
||||
|
||||
# mybatis config
|
||||
mybatis.mapper-locations=classpath*:mapper/**/*Mapper.xml
|
||||
|
||||
mybatis.configuration.call-setters-on-nulls=true
|
||||
mybatis.configuration.map-underscore-to-camel-case=true
|
||||
|
||||
com.alipay.sofa.rpc.registry.address=zookeeper://tzk.coolcollege.cn:2188
|
||||
com.alipay.sofa.rpc.bolt.port=30910
|
||||
@@ -0,0 +1,41 @@
|
||||
#mysql config
|
||||
default.datasource.url=jdbc:mysql://dingpushcoolcollege.mysql.rds.aliyuncs.com:3306/coolcollege_intelligent_config?useSSL=false&useUnicode=true&characterEncoding=utf8&allowMultiQueries=true&autoReconnect=true
|
||||
#default.datasource.url=jdbc:mysql://dstore-coolcollege.mysql.rds.aliyuncs.com:3306/coolcollege_intelligent_config?useSSL=false&useUnicode=true&characterEncoding=utf8&allowMultiQueries=true&autoReconnect=true&serverTimezone=Asia/Shanghai
|
||||
default.datasource.username=coolstore
|
||||
default.datasource.password=CSCErYcXniNYm7bT
|
||||
#default.datasource.url=jdbc:mysql://127.0.0.1:3306/coolcollege_intelligent_config?useSSL=false&useUnicode=true&characterEncoding=utf8&allowMultiQueries=true&autoReconnect=true&serverTimezone=Asia/Shanghai
|
||||
#default.datasource.username=root
|
||||
#default.datasource.password=root
|
||||
|
||||
#redis
|
||||
spring.redis.host=tstore-coolcollege.redis.rds.aliyuncs.com
|
||||
spring.redis.port=6379
|
||||
spring.redis.password=Cx111111
|
||||
spring.redis.database=0
|
||||
spring.redis.timeout=2000ms
|
||||
spring.redis.lettuce.pool.max-wait=100ms
|
||||
spring.redis.lettuce.pool.max-active=1024
|
||||
spring.redis.lettuce.pool.max-idle=200
|
||||
spring.redis.lettuce.pool.min-idle=0
|
||||
spring.redis.lettuce.shutdown-timeout=100ms
|
||||
redis.host.uri=http://userInfo:Cx111111@tstore-coolcollege.redis.rds.aliyuncs.com:6379/0
|
||||
redis.isv.host.uri=http://userInfo:Cx111111@tstore-coolcollege.redis.rds.aliyuncs.com:6379/2
|
||||
|
||||
#pagehelper
|
||||
pagehelper.helper-dialect=mysql
|
||||
pagehelper.reasonable=false
|
||||
pagehelper.returnPageInfo=check
|
||||
pagehelper.support-methods-arguments=false
|
||||
pagehelper.params=count=countSql
|
||||
pagehelper.page-size-zero=true
|
||||
|
||||
spring.mvc.async.request-timeout=60000
|
||||
|
||||
# mybatis config
|
||||
mybatis.mapper-locations=classpath*:mapper/**/*Mapper.xml
|
||||
|
||||
mybatis.configuration.call-setters-on-nulls=true
|
||||
mybatis.configuration.map-underscore-to-camel-case=true
|
||||
|
||||
com.alipay.sofa.rpc.registry.address=zookeeper://dzk.coolcollege.cn:2188
|
||||
com.alipay.sofa.rpc.bolt.port=30910
|
||||
@@ -0,0 +1,37 @@
|
||||
#mysql config
|
||||
default.datasource.url=jdbc:mysql://store-coolcollege.mysql.rds.aliyuncs.com:3306/coolcollege_intelligent_config?useUnicode=true&characterEncoding=UTF-8&useSSL=false&autoReconnect=true&failOverReadOnly=false&serverTimezone=Asia/Shanghai&allowMultiQueries=true
|
||||
default.datasource.username=coolstore
|
||||
default.datasource.password=CSCErYcXniNYm7bT
|
||||
|
||||
#redis
|
||||
spring.redis.host=store-coolcollege.redis.rds.aliyuncs.com
|
||||
spring.redis.port=6379
|
||||
spring.redis.password=Cx111111
|
||||
spring.redis.database=0
|
||||
spring.redis.timeout=2000ms
|
||||
spring.redis.lettuce.pool.max-wait=100ms
|
||||
spring.redis.lettuce.pool.max-active=1024
|
||||
spring.redis.lettuce.pool.max-idle=200
|
||||
spring.redis.lettuce.pool.min-idle=0
|
||||
spring.redis.lettuce.shutdown-timeout=100ms
|
||||
redis.host.uri=http://userInfo:Cx111111@store-coolcollege.redis.rds.aliyuncs.com:6379/0
|
||||
redis.isv.host.uri=http://userInfo:Cx111111@store-coolcollege.redis.rds.aliyuncs.com:6379/2
|
||||
|
||||
#pagehelper
|
||||
pagehelper.helper-dialect=mysql
|
||||
pagehelper.reasonable=false
|
||||
pagehelper.returnPageInfo=check
|
||||
pagehelper.support-methods-arguments=false
|
||||
pagehelper.params=count=countSql
|
||||
pagehelper.page-size-zero=true
|
||||
|
||||
spring.mvc.async.request-timeout=60000
|
||||
|
||||
# mybatis config
|
||||
mybatis.mapper-locations=classpath*:mapper/**/*Mapper.xml
|
||||
|
||||
mybatis.configuration.call-setters-on-nulls=true
|
||||
mybatis.configuration.map-underscore-to-camel-case=true
|
||||
|
||||
com.alipay.sofa.rpc.registry.address=zookeeper://10.7.53.199:2188
|
||||
com.alipay.sofa.rpc.bolt.port=30910
|
||||
@@ -0,0 +1,44 @@
|
||||
#mysql config
|
||||
default.datasource.url=jdbc:mysql://dingpushcoolcollege.mysql.rds.aliyuncs.com:3306/coolcollege_intelligent_config?useSSL=false&useUnicode=true&characterEncoding=utf8&allowMultiQueries=true&autoReconnect=true
|
||||
#default.datasource.url=jdbc:mysql://dstore-coolcollege.mysql.rds.aliyuncs.com:3306/coolcollege_intelligent_config?useSSL=false&useUnicode=true&characterEncoding=utf8&allowMultiQueries=true&autoReconnect=true&serverTimezone=Asia/Shanghai
|
||||
default.datasource.username=coolstore
|
||||
default.datasource.password=CSCErYcXniNYm7bT
|
||||
#default.datasource.url=jdbc:mysql://127.0.0.1:3306/coolcollege_intelligent_config?useSSL=false&useUnicode=true&characterEncoding=utf8&allowMultiQueries=true&autoReconnect=true&serverTimezone=Asia/Shanghai
|
||||
#default.datasource.username=root
|
||||
#default.datasource.password=root
|
||||
|
||||
#redis
|
||||
spring.redis.host=tstore-coolcollege.redis.rds.aliyuncs.com
|
||||
spring.redis.port=6379
|
||||
spring.redis.password=Cx111111
|
||||
spring.redis.database=0
|
||||
spring.redis.timeout=2000ms
|
||||
spring.redis.lettuce.pool.max-wait=100ms
|
||||
spring.redis.lettuce.pool.max-active=1024
|
||||
spring.redis.lettuce.pool.max-idle=200
|
||||
spring.redis.lettuce.pool.min-idle=0
|
||||
spring.redis.lettuce.shutdown-timeout=100ms
|
||||
redis.host.uri=http://userInfo:Cx111111@tstore-coolcollege.redis.rds.aliyuncs.com:6379/0
|
||||
redis.isv.host.uri=http://userInfo:Cx111111@tstore-coolcollege.redis.rds.aliyuncs.com:6379/2
|
||||
|
||||
#pagehelper
|
||||
pagehelper.helper-dialect=mysql
|
||||
pagehelper.reasonable=false
|
||||
pagehelper.returnPageInfo=check
|
||||
pagehelper.support-methods-arguments=false
|
||||
pagehelper.params=count=countSql
|
||||
pagehelper.page-size-zero=true
|
||||
|
||||
spring.mvc.async.request-timeout=60000
|
||||
|
||||
# mybatis config
|
||||
mybatis.mapper-locations=classpath*:mapper/**/*Mapper.xml
|
||||
|
||||
#subtable size
|
||||
customize_sub_table_size=10
|
||||
|
||||
mybatis.configuration.call-setters-on-nulls=true
|
||||
mybatis.configuration.map-underscore-to-camel-case=true
|
||||
|
||||
com.alipay.sofa.rpc.registry.address=zookeeper://localhost:2181
|
||||
com.alipay.sofa.rpc.bolt.port=30910
|
||||
@@ -0,0 +1,37 @@
|
||||
#mysql config
|
||||
default.datasource.url=jdbc:mysql://store-coolcollege.mysql.rds.aliyuncs.com:3306/coolcollege_intelligent_config?useUnicode=true&characterEncoding=UTF-8&useSSL=false&autoReconnect=true&failOverReadOnly=false&serverTimezone=Asia/Shanghai&allowMultiQueries=true
|
||||
default.datasource.username=coolstore
|
||||
default.datasource.password=CSCErYcXniNYm7bT
|
||||
|
||||
#redis
|
||||
spring.redis.host=store-coolcollege.redis.rds.aliyuncs.com
|
||||
spring.redis.port=6379
|
||||
spring.redis.password=Cx111111
|
||||
spring.redis.database=0
|
||||
spring.redis.timeout=2000ms
|
||||
spring.redis.lettuce.pool.max-wait=100ms
|
||||
spring.redis.lettuce.pool.max-active=1024
|
||||
spring.redis.lettuce.pool.max-idle=200
|
||||
spring.redis.lettuce.pool.min-idle=0
|
||||
spring.redis.lettuce.shutdown-timeout=100ms
|
||||
redis.host.uri=http://userInfo:Cx111111@store-coolcollege.redis.rds.aliyuncs.com:6379/0
|
||||
redis.isv.host.uri=http://userInfo:Cx111111@store-coolcollege.redis.rds.aliyuncs.com:6379/2
|
||||
|
||||
#pagehelper
|
||||
pagehelper.helper-dialect=mysql
|
||||
pagehelper.reasonable=false
|
||||
pagehelper.returnPageInfo=check
|
||||
pagehelper.support-methods-arguments=false
|
||||
pagehelper.params=count=countSql
|
||||
pagehelper.page-size-zero=true
|
||||
|
||||
spring.mvc.async.request-timeout=60000
|
||||
|
||||
# mybatis config
|
||||
mybatis.mapper-locations=classpath*:mapper/**/*Mapper.xml
|
||||
|
||||
mybatis.configuration.call-setters-on-nulls=true
|
||||
mybatis.configuration.map-underscore-to-camel-case=true
|
||||
|
||||
com.alipay.sofa.rpc.registry.address=zookeeper://10.6.49.221:2188,10.6.49.222:2188,10.6.49.223:2188
|
||||
com.alipay.sofa.rpc.bolt.port=30910
|
||||
@@ -0,0 +1,37 @@
|
||||
#mysql config
|
||||
default.datasource.url=jdbc:mysql://store-coolcollege.mysql.rds.aliyuncs.com:3306/coolcollege_intelligent_config?useUnicode=true&characterEncoding=UTF-8&useSSL=false&autoReconnect=true&failOverReadOnly=false&serverTimezone=Asia/Shanghai&allowMultiQueries=true
|
||||
default.datasource.username=coolstore
|
||||
default.datasource.password=CSCErYcXniNYm7bT
|
||||
|
||||
#redis
|
||||
spring.redis.host=store-coolcollege.redis.rds.aliyuncs.com
|
||||
spring.redis.port=6379
|
||||
spring.redis.password=Cx111111
|
||||
spring.redis.database=0
|
||||
spring.redis.timeout=2000ms
|
||||
spring.redis.lettuce.pool.max-wait=100ms
|
||||
spring.redis.lettuce.pool.max-active=1024
|
||||
spring.redis.lettuce.pool.max-idle=200
|
||||
spring.redis.lettuce.pool.min-idle=0
|
||||
spring.redis.lettuce.shutdown-timeout=100ms
|
||||
redis.host.uri=http://userInfo:Cx111111@store-coolcollege.redis.rds.aliyuncs.com:6379/0
|
||||
redis.isv.host.uri=http://userInfo:Cx111111@store-coolcollege.redis.rds.aliyuncs.com:6379/2
|
||||
|
||||
#pagehelper
|
||||
pagehelper.helper-dialect=mysql
|
||||
pagehelper.reasonable=false
|
||||
pagehelper.returnPageInfo=check
|
||||
pagehelper.support-methods-arguments=false
|
||||
pagehelper.params=count=countSql
|
||||
pagehelper.page-size-zero=true
|
||||
|
||||
spring.mvc.async.request-timeout=60000
|
||||
|
||||
# mybatis config
|
||||
mybatis.mapper-locations=classpath*:mapper/**/*Mapper.xml
|
||||
|
||||
mybatis.configuration.call-setters-on-nulls=true
|
||||
mybatis.configuration.map-underscore-to-camel-case=true
|
||||
|
||||
com.alipay.sofa.rpc.registry.address=zookeeper://10.7.54.149:2188
|
||||
com.alipay.sofa.rpc.bolt.port=30910
|
||||
@@ -0,0 +1,37 @@
|
||||
#mysql config
|
||||
default.datasource.url=jdbc:mysql://dingpushcoolcollege.mysql.rds.aliyuncs.com:3306/coolcollege_intelligent_config?useSSL=false&useUnicode=true&characterEncoding=utf8&allowMultiQueries=true&autoReconnect=true&serverTimezone=Asia/Shanghai
|
||||
default.datasource.username=coolstore
|
||||
default.datasource.password=CSCErYcXniNYm7bT
|
||||
|
||||
#redis
|
||||
spring.redis.host=tstore-coolcollege.redis.rds.aliyuncs.com
|
||||
spring.redis.port=6379
|
||||
spring.redis.password=Cx111111
|
||||
spring.redis.database=0
|
||||
spring.redis.timeout=2000ms
|
||||
spring.redis.lettuce.pool.max-wait=100ms
|
||||
spring.redis.lettuce.pool.max-active=1024
|
||||
spring.redis.lettuce.pool.max-idle=200
|
||||
spring.redis.lettuce.pool.min-idle=0
|
||||
spring.redis.lettuce.shutdown-timeout=100ms
|
||||
redis.host.uri=http://userInfo:Cx111111@tstore-coolcollege.redis.rds.aliyuncs.com:6379/0
|
||||
redis.isv.host.uri=http://userInfo:Cx111111@tstore-coolcollege.redis.rds.aliyuncs.com:6379/2
|
||||
|
||||
#pagehelper
|
||||
pagehelper.helper-dialect=mysql
|
||||
pagehelper.reasonable=false
|
||||
pagehelper.returnPageInfo=check
|
||||
pagehelper.support-methods-arguments=false
|
||||
pagehelper.params=count=countSql
|
||||
pagehelper.page-size-zero=true
|
||||
|
||||
spring.mvc.async.request-timeout=60000
|
||||
|
||||
# mybatis config
|
||||
mybatis.mapper-locations=classpath*:mapper/**/*Mapper.xml
|
||||
|
||||
mybatis.configuration.call-setters-on-nulls=true
|
||||
mybatis.configuration.map-underscore-to-camel-case=true
|
||||
|
||||
com.alipay.sofa.rpc.registry.address=zookeeper://tzk.coolcollege.cn:2188
|
||||
com.alipay.sofa.rpc.bolt.port=30910
|
||||
@@ -0,0 +1,52 @@
|
||||
spring.application.name=coolstore-partner-webc
|
||||
spring.profiles.active=@profileActive@
|
||||
|
||||
server.port=30900
|
||||
server.servlet.context-path=/partner
|
||||
|
||||
#logback
|
||||
logging.config=classpath:logback-spring.xml
|
||||
logging.path=/data/log/partner
|
||||
|
||||
#connection pool config
|
||||
spring.datasource.hikari.driver-class-name=com.mysql.cj.jdbc.Driver
|
||||
spring.datasource.hikari.cachePrepStmts=true
|
||||
spring.datasource.hikari.prepStmtCacheSize=250
|
||||
spring.datasource.hikari.prepStmtCacheSqlLimit=2048
|
||||
spring.datasource.hikari.useServerPrepStmts=true
|
||||
spring.datasource.hikari.useLocalSessionState=true
|
||||
spring.datasource.hikari.rewriteBatchedStatements=true
|
||||
spring.datasource.hikari.cacheResultSetMetadata=true
|
||||
spring.datasource.hikari.cacheServerConfiguration=true
|
||||
spring.datasource.hikari.elideSetAutoCommits=true
|
||||
spring.datasource.hikari.maintainTimeStats=false
|
||||
spring.datasource.hikari.minimumIdle=10
|
||||
spring.datasource.hikari.maximumPoolSize=150
|
||||
spring.datasource.hikari.maxLifetime=200000
|
||||
spring.datasource.hikari.connectionTimeout=3000
|
||||
spring.datasource.hikari.poolName=DefaultHikariCP
|
||||
spring.datasource.hikari.idleTimeout=300000
|
||||
#\u914D\u7F6E\u8FD4\u56DE\u65F6\u95F4\u6233
|
||||
spring.jackson.serialization.write-dates-as-timestamps=true
|
||||
# file size
|
||||
spring.servlet.multipart.maxFileSize=1024MB
|
||||
spring.servlet.multipart.maxRequestSize=1024MB
|
||||
# Max file size.
|
||||
spring.servlet.multipart.max-file-size=1024MB
|
||||
# Max request size.
|
||||
spring.servlet.multipart.max-request-size=1024MB
|
||||
spring.main.allow-circular-references=true
|
||||
|
||||
allow.upload.image.ext=jpg,jpeg,gif,png,bmp,jfif
|
||||
allow.upload.file.ext=zip,mp4,pptx,ppt,doc,docx,pdf
|
||||
allow.upload.video.ext=3gp,asf,avi,dat,dv,flv,f4v,gif,m2t,m3u8,m4v,mj2,mjpeg,mkv,mov,mp4,mpe,mpg,mpeg,mts,ogg,qt,rm,rmvb,swf,ts,vob,wmv,webm
|
||||
allow.upload.audio.ext=mp3
|
||||
allow.upload.image.size=1024 * 1024L * 1024L
|
||||
allow.upload.file.size=30 * 1024 * 1024L
|
||||
allow.upload.video.size=1024 * 1024 * 10L
|
||||
allow.upload.audio.size=1024 * 1024 * 10L
|
||||
|
||||
server.connection-timeout=18000000
|
||||
server.tomcat.basedir=/tmp/tomcat/partner-c
|
||||
|
||||
log4j2.formatMsgNoLookups=true
|
||||
58
coolstore-partner-webc/src/main/resources/logback-spring.xml
Normal file
58
coolstore-partner-webc/src/main/resources/logback-spring.xml
Normal file
@@ -0,0 +1,58 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--scan:配置文件如果发生改变,将会被重新加载,scanPeriod:设置监测配置文件是否有修改的时间间隔 -->
|
||||
<configuration scan="true" scanPeriod="60 seconds">
|
||||
<!--应用的名称 -->
|
||||
<property name="APPNAME" value="partner-web-c" />
|
||||
<!--应用的端口号 -->
|
||||
<property name="PORT" value="30900" />
|
||||
<!--日志文件本地存放目录路径-->
|
||||
<property name="logBaseFolder" value="/data/log/partner" />
|
||||
<!--日志文件名称的前缀部分 -->
|
||||
<property name="logFileNamePrefix" value="${APPNAME}-${PORT}" />
|
||||
<!--日志文件最小切割单位 -->
|
||||
<property name="every_file_size" value="300MB" />
|
||||
<!--日志文件保存时间 -->
|
||||
<property name="every_his_size" value="5" />
|
||||
<!--用来指定日志文件的上限大小,删除旧的日志 -->
|
||||
<property name="every_max_size" value="20GB" />
|
||||
<!-- 日志文件的编码 -->
|
||||
<property name="log_charset" value="UTF-8" />
|
||||
<!--|日志时间|线程id|端口号|应用名称|类名|方法名|日志级别|traceId |输入参数|输出参数|耗时|任意多个扩展字段|具体打印的msg内容然后换行-->
|
||||
<property name="log_pattern" value="|%d{yyyy-MM-dd HH:mm:ss.SSS}|%t|${APPNAME}|[%X{requestId}]|[%X{messageId}]%logger|%M|%p|%m%n"/>
|
||||
|
||||
<!-- 输出到控制台 -->
|
||||
<appender name="stdout" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
|
||||
<level>DEBUG</level>
|
||||
</filter>
|
||||
<encoder>
|
||||
<pattern>${log_pattern}</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
<!-- 核心系统日志输出到文件,基于日志大小和时间归档 -->
|
||||
<appender name="rollingFile"
|
||||
class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">>
|
||||
<fileNamePattern>${logBaseFolder}/${logFileNamePrefix}.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||
<maxHistory>${every_his_size}</maxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>${log_pattern}</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<logger name="com.cool.store.mapper" level="DEBUG" additivity="true" />
|
||||
<!--灰度、线上、预防 不输出到console-->
|
||||
<springProfile name="hd,online,pre">
|
||||
<root level="info">
|
||||
<appender-ref ref="rollingFile"/>
|
||||
</root>
|
||||
</springProfile>
|
||||
|
||||
<springProfile name="ab,dev,test,local">
|
||||
<root level="info">
|
||||
<appender-ref ref="stdout"/>
|
||||
</root>
|
||||
</springProfile>
|
||||
|
||||
</configuration>
|
||||
Reference in New Issue
Block a user