Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Y
yudao-cloud
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
hblj
yudao-cloud
Commits
4a2870e8
提交
4a2870e8
authored
4月 12, 2020
作者:
YunaiV
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
将 promotion 模块接入 SCA Dubbo 和 Nacos Discovery 组件,同时将 Seata 修改成 SCA Seata 组件
上级
ac2ee0a1
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
42 行增加
和
189 行删除
+42
-189
pom.xml
promotion/pom.xml
+12
-0
pom.xml
promotion/promotion-service-impl/pom.xml
+4
-21
DatabaseConfiguration.java
...oder/mall/promotion/biz/config/DatabaseConfiguration.java
+0
-68
application-test.yaml
...vice-impl/src/main/resources/config/application-test.yaml
+0
-7
application.yaml
...n-service-impl/src/main/resources/config/application.yaml
+26
-10
file.conf
...otion/promotion-service-impl/src/main/resources/file.conf
+0
-69
registry.conf
...n/promotion-service-impl/src/main/resources/registry.conf
+0
-14
没有找到文件。
promotion/pom.xml
浏览文件 @
4a2870e8
...
@@ -17,4 +17,16 @@
...
@@ -17,4 +17,16 @@
<module>
promotion-application
</module>
<module>
promotion-application
</module>
</modules>
</modules>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>
cn.iocoder.mall
</groupId>
<artifactId>
common-dependencies
</artifactId>
<version>
1.0-SNAPSHOT
</version>
<type>
pom
</type>
<scope>
import
</scope>
</dependency>
</dependencies>
</dependencyManagement>
</project>
</project>
promotion/promotion-service-impl/pom.xml
浏览文件 @
4a2870e8
...
@@ -54,33 +54,16 @@
...
@@ -54,33 +54,16 @@
<artifactId>
mybatis-plus-boot-starter
</artifactId>
<artifactId>
mybatis-plus-boot-starter
</artifactId>
</dependency>
</dependency>
<dependency>
<groupId>
io.seata
</groupId>
<artifactId>
seata-spring
</artifactId>
</dependency>
<dependency>
<groupId>
io.seata
</groupId>
<artifactId>
seata-dubbo
</artifactId>
</dependency>
<!-- RPC 相关 -->
<!-- RPC 相关 -->
<dependency>
<dependency>
<groupId>
org.apache.dubbo
</groupId>
<groupId>
com.alibaba.cloud
</groupId>
<artifactId>
dubbo
</artifactId>
<artifactId>
spring-cloud-starter-dubbo
</artifactId>
</dependency>
<dependency>
<groupId>
org.apache.dubbo
</groupId>
<artifactId>
dubbo-spring-boot-starter
</artifactId>
</dependency>
</dependency>
<!-- Registry 和 Config 相关 -->
<!-- Registry 和 Config 相关 -->
<dependency>
<dependency>
<groupId>
org.apache.curator
</groupId>
<groupId>
com.alibaba.cloud
</groupId>
<artifactId>
curator-framework
</artifactId>
<artifactId>
spring-cloud-starter-alibaba-nacos-discovery
</artifactId>
</dependency>
<dependency>
<groupId>
org.apache.curator
</groupId>
<artifactId>
curator-recipes
</artifactId>
</dependency>
</dependency>
<!-- MQ 相关 -->
<!-- MQ 相关 -->
...
...
promotion/promotion-service-impl/src/main/java/cn/iocoder/mall/promotion/biz/config/DatabaseConfiguration.java
浏览文件 @
4a2870e8
package
cn
.
iocoder
.
mall
.
promotion
.
biz
.
config
;
package
cn
.
iocoder
.
mall
.
promotion
.
biz
.
config
;
import
com.alibaba.druid.pool.DruidDataSource
;
import
com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceBuilder
;
import
io.seata.rm.datasource.DataSourceProxy
;
import
io.seata.spring.annotation.GlobalTransactionScanner
;
import
org.mybatis.spring.annotation.MapperScan
;
import
org.mybatis.spring.annotation.MapperScan
;
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.Configuration
;
import
org.springframework.context.annotation.DependsOn
;
import
org.springframework.context.annotation.Primary
;
import
org.springframework.transaction.annotation.EnableTransactionManagement
;
import
org.springframework.transaction.annotation.EnableTransactionManagement
;
import
javax.sql.DataSource
;
@Configuration
@Configuration
@MapperScan
(
"cn.iocoder.mall.promotion.biz.dao"
)
// 扫描对应的 Mapper 接口
@MapperScan
(
"cn.iocoder.mall.promotion.biz.dao"
)
// 扫描对应的 Mapper 接口
@EnableTransactionManagement
(
proxyTargetClass
=
true
)
// 启动事务管理。为什么使用 proxyTargetClass 参数,参见 https://blog.csdn.net/huang_550/article/details/76492600
@EnableTransactionManagement
(
proxyTargetClass
=
true
)
// 启动事务管理。为什么使用 proxyTargetClass 参数,参见 https://blog.csdn.net/huang_550/article/details/76492600
...
@@ -23,61 +12,4 @@ public class DatabaseConfiguration {
...
@@ -23,61 +12,4 @@ public class DatabaseConfiguration {
// 数据源,使用 HikariCP
// 数据源,使用 HikariCP
@Value
(
"${spring.application.name}"
)
private
String
applicationId
;
// @Autowired
// private DataSourceProperties dataSourceProperties;
//
//// @Bean // TODO 芋艿,加了就一直报错,后面在找原因。
// @Primary
// public DruidDataSource druidDataSource(){
// DruidDataSource druidDataSource = new DruidDataSource();
// druidDataSource.setUrl(dataSourceProperties.getUrl());
// druidDataSource.setUsername(dataSourceProperties.getUsername());
// druidDataSource.setPassword(dataSourceProperties.getPassword());
// druidDataSource.setDriverClassName(dataSourceProperties.getDriverClassName());
// druidDataSource.setInitialSize(0);
// druidDataSource.setMaxActive(180);
// druidDataSource.setMaxWait(60000);
// druidDataSource.setMinIdle(0);
// druidDataSource.setValidationQuery("Select 1 from DUAL");
// druidDataSource.setTestOnBorrow(false);
// druidDataSource.setTestOnReturn(false);
// druidDataSource.setTestWhileIdle(true);
// druidDataSource.setTimeBetweenEvictionRunsMillis(60000);
// druidDataSource.setMinEvictableIdleTimeMillis(25200000);
// druidDataSource.setRemoveAbandoned(true);
// druidDataSource.setRemoveAbandonedTimeout(1800);
// druidDataSource.setLogAbandoned(true);
// return druidDataSource;
// }
@Bean
(
"druidDataSource"
)
@ConfigurationProperties
(
"spring.datasource.druid"
)
public
DruidDataSource
druidDataSource
(){
return
DruidDataSourceBuilder
.
create
().
build
();
}
@ConfigurationProperties
(
prefix
=
"spring.datasource"
)
@Primary
@Bean
(
"dataSource"
)
// @Bean
@DependsOn
(
"druidDataSource"
)
// 解决多数据源,循环依赖的问题。主要发生点在 DataSourceInitializerInvoker
public
DataSource
dataSource
()
{
DruidDataSource
druidDataSource
=
druidDataSource
();
return
new
DataSourceProxy
(
druidDataSource
);
}
/**
* 注册一个StatViewServlet
*
* @return global transaction scanner
*/
@Bean
public
GlobalTransactionScanner
globalTransactionScanner
()
{
return
new
GlobalTransactionScanner
(
applicationId
,
"my_test_tx_group"
);
// TODO 芋艿,txServiceGroup 后续要编辑下
}
}
}
promotion/promotion-service-impl/src/main/resources/config/application-test.yaml
deleted
100644 → 0
浏览文件 @
ac2ee0a1
spring
:
# datasource
datasource
:
url
:
jdbc:mysql://192.168.88.14:3306/mall_promotion?useSSL=false&useUnicode=true&characterEncoding=UTF-8
driver-class-name
:
com.mysql.jdbc.Driver
username
:
root
password
:
${MALL_MYSQL_PASSWORD}
promotion/promotion-service-impl/src/main/resources/config/application.yaml
浏览文件 @
4a2870e8
...
@@ -6,11 +6,13 @@ spring:
...
@@ -6,11 +6,13 @@ spring:
driver-class-name
:
com.mysql.jdbc.Driver
driver-class-name
:
com.mysql.jdbc.Driver
username
:
root
username
:
root
password
:
${MALL_MYSQL_PASSWORD}
password
:
${MALL_MYSQL_PASSWORD}
# TODO 芋艿, 后续优化下 druid 参数
druid
:
# Spring Cloud 配置项
initial-size
:
5
cloud
:
max-active
:
5
nacos
:
max-wait
:
10000
# Spring Cloud Nacos Discovery 配置项
discovery
:
server-addr
:
127.0.0.1:8848
# Nacos 服务器地址
# mybatis-plus
# mybatis-plus
mybatis-plus
:
mybatis-plus
:
...
@@ -22,20 +24,25 @@ mybatis-plus:
...
@@ -22,20 +24,25 @@ mybatis-plus:
mapper-locations
:
classpath*:mapper/*.xml
mapper-locations
:
classpath*:mapper/*.xml
type-aliases-package
:
cn.iocoder.mall.promotion.biz.dataobject
type-aliases-package
:
cn.iocoder.mall.promotion.biz.dataobject
#
dubbo
#
Dubbo 配置项
dubbo
:
dubbo
:
application
:
# Dubbo 注册中心
name
:
promotion-service
registry
:
registry
:
address
:
zookeeper://127.0.0.1:2181
address
:
spring-cloud://127.0.0.1:8848
# 指定 Dubbo 服务注册中心的地址
# Spring Cloud Alibaba Dubbo 专属配置
cloud
:
subscribed-services
:
admin-application, product-application
# 设置订阅的应用列表,默认为 * 订阅所有应用
# Dubbo 提供者的协议
protocol
:
protocol
:
port
:
-1
name
:
dubbo
name
:
dubbo
port
:
-1
# Dubbo 提供服务的扫描基础包
scan
:
scan
:
base-packages
:
cn.iocoder.mall.promotion.biz.service
base-packages
:
cn.iocoder.mall.promotion.biz.service
consumer
:
consumer
:
ProductSpuService
:
ProductSpuService
:
version
:
1.0.0
version
:
1.0.0
# Dubbo 服务提供者的配置
provider
:
provider
:
filter
:
-exception
filter
:
-exception
BannerService
:
BannerService
:
...
@@ -47,6 +54,15 @@ dubbo:
...
@@ -47,6 +54,15 @@ dubbo:
PromotionActivityService
:
PromotionActivityService
:
version
:
1.0.0
version
:
1.0.0
# Seata 配置项
seata
:
# Seata 注册中心配置项
registry
:
type
:
nacos
# 注册中心类型
nacos
:
serverAddr
:
${spring.cloud.nacos.discovery.server-addr}
# Nacos 服务地址
namespace
:
# Nacos 命名空间
cluster
:
default
# 使用的 Seata 分组
# logging
# logging
logging
:
logging
:
...
...
promotion/promotion-service-impl/src/main/resources/file.conf
deleted
100644 → 0
浏览文件 @
ac2ee0a1
transport
{
# tcp udt unix-domain-socket
type
=
"TCP"
#NIO NATIVE
server
=
"NIO"
#enable heartbeat
heartbeat
=
true
#thread factory for netty
thread
-
factory
{
boss
-
thread
-
prefix
=
"NettyBoss"
worker
-
thread
-
prefix
=
"NettyServerNIOWorker"
server
-
executor
-
thread
-
prefix
=
"NettyServerBizHandler"
share
-
boss
-
worker
=
false
client
-
selector
-
thread
-
prefix
=
"NettyClientSelector"
client
-
selector
-
thread
-
size
=
1
client
-
worker
-
thread
-
prefix
=
"NettyClientWorkerThread"
# netty boss thread size,will not be used for UDT
boss
-
thread
-
size
=
1
#auto default pin or 8
worker
-
thread
-
size
=
8
}
}
service
{
#vgroup->rgroup
vgroup_mapping
.
my_test_tx_group
=
"default"
#only support single node
default
.
grouplist
=
"180.167.213.26:8091"
#degrade current not support
enableDegrade
=
false
#disable
disable
=
false
}
client
{
async
.
commit
.
buffer
.
limit
=
10000
lock
{
retry
.
internal
=
10
retry
.
times
=
30
}
}
## transaction log store
store
{
## store mode: file、db
mode
=
"file"
## file store
file
{
dir
=
"file_store/data"
# branch session size , if exceeded first try compress lockkey, still exceeded throws exceptions
max
-
branch
-
session
-
size
=
16384
# globe session size , if exceeded throws exceptions
max
-
global
-
session
-
size
=
512
# file buffer size , if exceeded allocate new buffer
file
-
write
-
buffer
-
cache
-
size
=
16384
# when recover batch read size
session
.
reload
.
read_size
=
100
}
## database store
db
{
driver_class
=
""
url
=
""
user
=
""
password
=
""
}
}
promotion/promotion-service-impl/src/main/resources/registry.conf
deleted
100644 → 0
浏览文件 @
ac2ee0a1
registry
{
type
=
"file"
file
{
name
=
"file.conf"
}
zk
{
cluster
=
"default"
serverAddr
=
"192.168.88.10:2181"
session
.
timeout
=
6000
connect
.
timeout
=
2000
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论