Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yanxuan-qc-change-system
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
yx-qc-change-flow
yanxuan-qc-change-system
Commits
a33fb47e
Commit
a33fb47e
authored
May 07, 2025
by
韩兵
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add: 调整配置值
parent
53176963
Pipeline
#75082
passed with stages
in 2 minutes 13 seconds
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
77 additions
and
66 deletions
+77
-66
pom.xml
pom.xml
+19
-0
application.properties
...y/src/main/resources/config/online/application.properties
+5
-0
application.properties
...c/main/resources/config/regression/application.properties
+6
-0
application.properties
...bly/src/main/resources/config/test/application.properties
+6
-0
pom.xml
yanxuan-qc-change-system-dal/pom.xml
+8
-6
DataSourceConfiguration.java
...il/yanxuan/change/dal/config/DataSourceConfiguration.java
+33
-60
No files found.
pom.xml
View file @
a33fb47e
...
...
@@ -44,6 +44,7 @@
<!-- store-db -->
<mysql.version>
5.1.34
</mysql.version>
<mybatis.spring.boot.starter.version>
1.1.1
</mybatis.spring.boot.starter.version>
<druid.version>
1.0.21
</druid.version>
<!-- store-redis -->
<redis.clients.version>
2.9.0
</redis.clients.version>
...
...
@@ -62,6 +63,7 @@
<commons.lang.version>
2.4
</commons.lang.version>
<des.version>
1.0.2-SNAPSHOT
</des.version>
<mapstruct.version>
1.3.1.Final
</mapstruct.version>
<pandora.version>
1.1.0-SNAPSHOT
</pandora.version>
</properties>
<!-- 子模块可选依赖 -->
...
...
@@ -184,6 +186,17 @@
<artifactId>
mybatis-spring-boot-starter
</artifactId>
<version>
${mybatis.spring.boot.starter.version}
</version>
</dependency>
<dependency>
<groupId>
com.alibaba
</groupId>
<artifactId>
druid
</artifactId>
<version>
${druid.version}
</version>
</dependency>
<!--引入潘多拉-->
<dependency>
<groupId>
com.netease.yanxuan
</groupId>
<artifactId>
pandora
</artifactId>
<version>
${pandora.version}
</version>
</dependency>
<!-- store-redis -->
<dependency>
...
...
@@ -196,6 +209,12 @@
<artifactId>
spring-data-redis
</artifactId>
<version>
${spring.data.redis.version}
</version>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-data-redis
</artifactId>
<version>
${spring.boot.version}
</version>
</dependency>
<dependency>
<groupId>
com.netease.yanxuan
</groupId>
...
...
yanxuan-qc-change-system-assembly/src/main/resources/config/online/application.properties
View file @
a33fb47e
...
...
@@ -19,6 +19,11 @@ server.tomcat.basedir=/home/logs/access
server.tomcat.accesslog.enabled
=
true
server.tomcat.accesslog.pattern
=
%h %l %u %t "%r" %s %b %{X-Forwarded-For}i %D %{P_INFO}c %{Referer}i %{User-Agent}i %{Host}i
# mybatis
mybatis.mapper-locations
=
classpath:mybatis/mapper/*.xml
mybatis.configuration.cache-enabled
=
true
mybatis.configuration.map-underscore-to-camel-case
=
true
# supplier
supplier.url
=
http://127.0.0.1:8550/proxy/online.yanxuan-supplier-ms.service.mailsaas
...
...
yanxuan-qc-change-system-assembly/src/main/resources/config/regression/application.properties
View file @
a33fb47e
...
...
@@ -18,6 +18,12 @@ server.tomcat.basedir=/home/logs/access
server.tomcat.accesslog.enabled
=
true
server.tomcat.accesslog.pattern
=
%h %l %u %t "%r" %s %b %{X-Forwarded-For}i %D %{P_INFO}c %{Referer}i %{User-Agent}i %{Host}i
# mybatis
mybatis.mapper-locations
=
classpath:mybatis/mapper/*.xml
mybatis.configuration.cache-enabled
=
true
mybatis.configuration.map-underscore-to-camel-case
=
true
# supplier
supplier.url
=
http://127.0.0.1:8550/proxy/regression.yanxuan-supplier-ms.service.mailsaas
...
...
yanxuan-qc-change-system-assembly/src/main/resources/config/test/application.properties
View file @
a33fb47e
...
...
@@ -21,6 +21,12 @@ server.tomcat.accesslog.enabled=true
server.tomcat.accesslog.pattern
=
%h %l %u %t "%r" %s %b %{X-Forwarded-For}i %D %{P_INFO}c %{Referer}i %{User-Agent}i %{Host}i
# mybatis
mybatis.mapper-locations
=
classpath:mybatis/mapper/*.xml
mybatis.configuration.cache-enabled
=
true
mybatis.configuration.map-underscore-to-camel-case
=
true
# supplier
supplier.url
=
http://127.0.0.1:8550/proxy/test.yanxuan-supplier-ms.service.mailsaas
...
...
yanxuan-qc-change-system-dal/pom.xml
View file @
a33fb47e
...
...
@@ -26,6 +26,14 @@
<groupId>
mysql
</groupId>
<artifactId>
mysql-connector-java
</artifactId>
</dependency>
<dependency>
<groupId>
com.alibaba
</groupId>
<artifactId>
druid
</artifactId>
</dependency>
<dependency>
<groupId>
com.netease.yanxuan
</groupId>
<artifactId>
pandora
</artifactId>
</dependency>
<!--store-redis-->
<dependency>
...
...
@@ -40,11 +48,6 @@
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-data-redis
</artifactId>
</dependency>
<dependency>
<groupId>
commons-dbcp
</groupId>
<artifactId>
commons-dbcp
</artifactId>
<version>
1.4
</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
yanxuan-qc-change-system-dal/src/main/java/com/netease/mail/yanxuan/change/dal/config/DataSourceConfiguration.java
View file @
a33fb47e
package
com
.
netease
.
mail
.
yanxuan
.
change
.
dal
.
config
;
//import com.ctrip.framework.apollo.spring.annotation.EnableApolloConfig;
//import com.google.common.collect.ImmutableSet;
//import com.netease.yanxuan.pandora.DataSourceRefresher;
//import com.netease.yanxuan.pandora.spring.annotation.EnableDataSourceRefresh;
import
org.apache.commons.dbcp.BasicDataSource
;
import
org.apache.ibatis.session.SqlSessionFactory
;
import
org.mybatis.spring.SqlSessionFactoryBean
;
import
org.mybatis.spring.SqlSessionTemplate
;
import
org.mybatis.spring.annotation.MapperScan
;
import
com.alibaba.druid.filter.stat.StatFilter
;
import
com.alibaba.druid.pool.DruidDataSource
;
import
com.ctrip.framework.apollo.spring.annotation.EnableApolloConfig
;
import
com.google.common.collect.ImmutableSet
;
import
com.google.common.collect.Lists
;
import
com.netease.yanxuan.pandora.DataSourceRefresher
;
import
com.netease.yanxuan.pandora.spring.annotation.EnableDataSourceRefresh
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Primary
;
import
org.springframework.core.io.Resource
;
import
org.springframework.core.io.support.PathMatchingResourcePatternResolver
;
import
org.springframework.jdbc.datasource.DataSourceTransactionManager
;
import
org.springframework.transaction.PlatformTransactionManager
;
import
org.springframework.transaction.annotation.EnableTransactionManagement
;
import
javax.sql.DataSource
;
...
...
@@ -27,33 +23,32 @@ import java.util.Set;
* @author hzfengyuexin@corp.netease.com
*/
@Configuration
@EnableTransactionManagement
//@EnableApolloConfig("db-public")
//@EnableDataSourceRefresh
@MapperScan
(
basePackages
=
"com.netease.mail.yanxuan.change.dal.mapper"
,
sqlSessionFactoryRef
=
"sqlSessionFactoryBean"
)
@EnableTransactionManagement
(
proxyTargetClass
=
true
)
@EnableApolloConfig
(
"db-public"
)
@EnableDataSourceRefresh
public
class
DataSourceConfiguration
{
@Autowired
private
DrmDBConfig
drmDBConfig
;
//
/**
//
* pandora热切换数据源
//
* */
//
@Bean
//
public DataSourceRefresher dataSourceRefresher() {
//
DataSourceRefresher dataSourceRefresher = new DataSourceRefresher("db-public");
//
Set<String> dataSource = ImmutableSet.of("db.url", "db.driverClassName", "db.username", "db.password");
//
dataSourceRefresher.bindDataSourceWithPropertyKey("dataSource", dataSource);
//
return dataSourceRefresher;
//
}
/**
* pandora热切换数据源
* */
@Bean
public
DataSourceRefresher
dataSourceRefresher
()
{
DataSourceRefresher
dataSourceRefresher
=
new
DataSourceRefresher
(
"db-public"
);
Set
<
String
>
dataSource
=
ImmutableSet
.
of
(
"db.url"
,
"db.driverClassName"
,
"db.username"
,
"db.password"
);
dataSourceRefresher
.
bindDataSourceWithPropertyKey
(
"dataSource"
,
dataSource
);
return
dataSourceRefresher
;
}
/**
*
数据源
*
db
数据源
*/
@Bean
(
name
=
"dataSource"
)
@Primary
public
DataSource
dataSource
()
{
BasicDataSource
dataSource
=
new
Basic
DataSource
();
DruidDataSource
dataSource
=
new
Druid
DataSource
();
dataSource
.
setDriverClassName
(
drmDBConfig
.
getDriverClassName
());
dataSource
.
setUrl
(
drmDBConfig
.
getUrl
());
dataSource
.
setUsername
(
drmDBConfig
.
getUserName
());
...
...
@@ -73,41 +68,19 @@ public class DataSourceConfiguration {
// 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
dataSource
.
setTimeBetweenEvictionRunsMillis
(
60000
);
dataSource
.
setMinEvictableIdleTimeMillis
(
300000
);
//
StatFilter filter = new StatFilter();
//
filter.setSlowSqlMillis(5000);
//
filter.setLogSlowSql(true);
//
filter.setMergeSql(true);
//
dataSource.setProxyFilters(Lists.newArrayList(filter));
StatFilter
filter
=
new
StatFilter
();
filter
.
setSlowSqlMillis
(
5000
);
filter
.
setLogSlowSql
(
true
);
filter
.
setMergeSql
(
true
);
dataSource
.
setProxyFilters
(
Lists
.
newArrayList
(
filter
));
return
dataSource
;
}
@Bean
(
name
=
"sqlSessionFactoryBean"
)
@Primary
public
SqlSessionFactoryBean
sqlSessionFactoryBean
()
throws
Exception
{
SqlSessionFactoryBean
sqlSessionFactoryBean
=
new
SqlSessionFactoryBean
();
sqlSessionFactoryBean
.
setDataSource
(
dataSource
());
sqlSessionFactoryBean
.
setTypeAliasesPackage
(
"com.netease.mail.yanxuan.change.dal.entity,"
+
"com.netease.mail.yanxuan.change.dal.meta.model.po"
);
Resource
[]
resources
=
new
PathMatchingResourcePatternResolver
().
getResources
(
"classpath:mybatis/mapper/*.xml"
);
sqlSessionFactoryBean
.
setMapperLocations
(
resources
);
org
.
apache
.
ibatis
.
session
.
Configuration
configuration
=
new
org
.
apache
.
ibatis
.
session
.
Configuration
();
configuration
.
setMapUnderscoreToCamelCase
(
true
);
configuration
.
setCacheEnabled
(
true
);
// configuration.addInterceptor(new tk.mybatis.mapper.mapperhelper.());
sqlSessionFactoryBean
.
setConfiguration
(
configuration
);
return
sqlSessionFactoryBean
;
}
@Primary
@Bean
(
name
=
"sqlSessionTemplate"
)
public
SqlSessionTemplate
sqlSessionTemplate
(
SqlSessionFactory
sqlSessionFactory
)
{
return
new
SqlSessionTemplate
(
sqlSessionFactory
);
}
/**
* 用于事务管理
*/
@Bean
(
name
=
"transactionManager"
)
@Primary
public
PlatformTransactionManager
transactionManager
()
{
return
new
DataSourceTransactionManager
(
dataSource
());
@Bean
(
"transactionManager"
)
public
DataSourceTransactionManager
dataSourceTransactionManager
(
@Qualifier
(
"dataSource"
)
DataSource
dataSource
)
{
DataSourceTransactionManager
dataSourceTransactionManager
=
new
DataSourceTransactionManager
();
dataSourceTransactionManager
.
setDataSource
(
dataSource
);
return
dataSourceTransactionManager
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment