Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
iBiz4j Spring R7
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
iBiz-R7后台标准模板
iBiz4j Spring R7
提交
9e41ab8c
提交
9e41ab8c
编写于
7月 14, 2020
作者:
zhouweidong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
mp动态数据源
上级
0b172175
变更
6
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
141 行增加
和
26 行删除
+141
-26
%APP%Application.java.ftl
...ava/%SYS_PKGPATH%/%APP_PKGPATH%/%APP%Application.java.ftl
+10
-0
DevBootApplication.java.ftl
...t/src/main/java/%SYS_PKGPATH%/DevBootApplication.java.ftl
+10
-0
%DE%Mapper.java.ftl
...YS_PKGPATH%/core/%MOD_PKGPATH%/mapper/%DE%Mapper.java.ftl
+5
-0
pom.xml.ftl
SLN/%PUBPRJ%-dependencies/pom.xml.ftl
+15
-0
%SYS%%API%Application.java.ftl
..._PKGPATH%/%SYSAPI_PKGPATH%/%SYS%%API%Application.java.ftl
+10
-0
application-sys.yml.ftl
SLN/%PUBPRJ%-util/src/main/resources/application-sys.yml.ftl
+91
-26
未找到文件。
SLN/%PUBPRJ%-app/%PUBPRJ%-app-%APP_PKGPATH%/src/main/java/%SYS_PKGPATH%/%APP_PKGPATH%/%APP%Application.java.ftl
浏览文件 @
9e41ab8c
<#
ibiztemplate
>
TARGET
=
PSSYSAPP
</#
ibiztemplate
>
<#
assign
bDynamicDS
=
false
>
<#
list
sys
.
getAllPSDataEntities
()
as
entity
>
<#
if
(
entity
.
getStorageMode
()==
1
||
entity
.
getStorageMode
()==
2
)
&&
entity
.
getDSLink
()
!='DEFAULT'>
<#
assign
bDynamicDS
=
true
>
<#
break
>
</#
if
>
</#
list
>
package
${
pub
.
getPKGCodeName
()}.${
app
.
getPKGCodeName
()?
lower_case
};
import
lombok
.
extern
.
slf4j
.
Slf4j
;
...
...
@@ -42,6 +49,9 @@ import java.util.List;
<#
if
bmogo
==
false
>
org
.
springframework
.
boot
.
autoconfigure
.
mongo
.
MongoAutoConfiguration
.
class
,
</#
if
>
<#
if
bDynamicDS
>
com
.
alibaba
.
druid
.
spring
.
boot
.
autoconfigure
.
DruidDataSourceAutoConfigure
.
class
</#
if
>
})
public
class
${
app
.
getPKGCodeName
()}
Application
extends
WebMvcConfigurerAdapter
{
...
...
SLN/%PUBPRJ%-boot/src/main/java/%SYS_PKGPATH%/DevBootApplication.java.ftl
浏览文件 @
9e41ab8c
<#
ibiztemplate
>
TARGET
=
PSSYSTEM
</#
ibiztemplate
>
<#
assign
bDynamicDS
=
false
>
<#
list
sys
.
getAllPSDataEntities
()
as
entity
>
<#
if
(
entity
.
getStorageMode
()==
1
||
entity
.
getStorageMode
()==
2
)
&&
entity
.
getDSLink
()
!='DEFAULT'>
<#
assign
bDynamicDS
=
true
>
<#
break
>
</#
if
>
</#
list
>
package
${
pub
.
getPKGCodeName
()};
import
lombok
.
extern
.
slf4j
.
Slf4j
;
...
...
@@ -36,6 +43,9 @@ import java.util.List;
<#
if
bmogo
==
false
>
org
.
springframework
.
boot
.
autoconfigure
.
mongo
.
MongoAutoConfiguration
.
class
,
</#
if
>
<#
if
bDynamicDS
>
com
.
alibaba
.
druid
.
spring
.
boot
.
autoconfigure
.
DruidDataSourceAutoConfigure
.
class
</#
if
>
})
@
ComponentScan
(
basePackages
=
{
"${pub.getPKGCodeName()}"
}
//
,
excludeFilters
={
...
...
SLN/%PUBPRJ%-core/src/main/java/%SYS_PKGPATH%/core/%MOD_PKGPATH%/mapper/%DE%Mapper.java.ftl
浏览文件 @
9e41ab8c
...
...
@@ -21,6 +21,11 @@ import java.io.Serializable;
import
com
.
baomidou
.
mybatisplus
.
core
.
toolkit
.
Constants
;
import
com
.
alibaba
.
fastjson
.
JSONObject
;
<#
if
item
.
getDSLink
??
&&
item
.
getDSLink
()??>
<#
if
item
.
getDSLink
()
!='DEFAULT'>
@
com
.
baomidou
.
dynamic
.
datasource
.
annotation
.
DS
(
"${item.getDSLink()?lower_case}"
)
</#
if
>
</#
if
>
public
interface
${
item
.
getCodeName
()}
Mapper
extends
BaseMapper
<${
item
.
getCodeName
()}>{
<#
if
item
.
getAllPSDEDataSets
()??>
...
...
SLN/%PUBPRJ%-dependencies/pom.xml.ftl
浏览文件 @
9e41ab8c
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
<#assign bDynamicDS=false>
<#list sys.getAllPSDataEntities() as entity>
<#if (entity.getStorageMode()==1 || entity.getStorageMode()==2) && entity.getDSLink()!='DEFAULT'>
<#assign bDynamicDS=true>
<#break>
</#if>
</#list>
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
...
...
@@ -363,6 +370,14 @@ TARGET=PSSYSTEM
</#list>
</#if>
<#if bDynamicDS>
<!-- mp动态数据源 -->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>dynamic-datasource-spring-boot-starter</artifactId>
</dependency>
</#if>
</dependencies>
</project>
SLN/%PUBPRJ%-provider/%PUBPRJ%-provider-%SYSAPI_PKGPATH%/src/main/java/%SYS_PKGPATH%/%SYSAPI_PKGPATH%/%SYS%%API%Application.java.ftl
浏览文件 @
9e41ab8c
<#
ibiztemplate
>
TARGET
=
PSSYSSERVICEAPI
</#
ibiztemplate
>
<#
assign
bDynamicDS
=
false
>
<#
list
sys
.
getAllPSDataEntities
()
as
entity
>
<#
if
(
entity
.
getStorageMode
()==
1
||
entity
.
getStorageMode
()==
2
)
&&
entity
.
getDSLink
()
!='DEFAULT'>
<#
assign
bDynamicDS
=
true
>
<#
break
>
</#
if
>
</#
list
>
package
${
pub
.
getPKGCodeName
()}.${
item
.
codeName
?
lower_case
};
import
lombok
.
extern
.
slf4j
.
Slf4j
;
...
...
@@ -45,6 +52,9 @@ import java.util.List;
<#
if
bmogo
==
false
>
org
.
springframework
.
boot
.
autoconfigure
.
mongo
.
MongoAutoConfiguration
.
class
,
</#
if
>
<#
if
bDynamicDS
>
com
.
alibaba
.
druid
.
spring
.
boot
.
autoconfigure
.
DruidDataSourceAutoConfigure
.
class
</#
if
>
})
@
Import
({
org
.
springframework
.
cloud
.
openfeign
.
FeignClientsConfiguration
.
class
...
...
SLN/%PUBPRJ%-util/src/main/resources/application-sys.yml.ftl
浏览文件 @
9e41ab8c
...
...
@@ -10,6 +10,13 @@ TARGET=PSSYSTEM
<#assign dbPassWord="root">
<#assign dbUrl="jdbc:mysql://127.0.0.1:3306/"+sys.name+"?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8&useOldAliasMetadataBehavior=true">
<#assign dbDriver="com.mysql.jdbc.Driver">
<#assign bDynamicDS=false>
<#list sys.getAllPSDataEntities() as entity>
<#if (entity.getStorageMode()==1 || entity.getStorageMode()==2) && entity.getDSLink()!='DEFAULT'>
<#assign bDynamicDS=true>
<#break>
</#if>
</#list>
<#comment>前端应用微服务平台配置</#comment>
<#if sys.getAllPSDevSlnMSDepApps()??>
<#list sys.getAllPSDevSlnMSDepApps() as depApp>
...
...
@@ -144,32 +151,11 @@ spring:
max-wait: 300ms
max-idle: 16
min-idle: 8
datasource:
username: ${dbUserName}
password: '${dbPassWord}'
url: ${dbUrl}
driver-class-name: ${dbDriver}
filters: stat,wall,log4j2
#配置初始化大小/最小/最大
initial-size: 1
min-idle: 1
max-active: 20
#获取连接等待超时时间
max-wait: 60000
#间隔多久进行一次检测,检测需要关闭的空闲连接
time-between-eviction-runs-millis: 60000
#一个连接在池中最小生存的时间
min-evictable-idle-time-millis: 300000
validation-query: SELECT 1 FROM DUAL
test-while-idle: true
test-on-borrow: false
test-on-return: false
#打开PSCache,并指定每个连接上PSCache的大小。oracle设为true,mysql设为false。分库分表较多推荐设置为false
pool-prepared-statements: false
max-pool-prepared-statement-per-connection-size: 20
isSyncDBSchema: false
defaultSchema: ${dbUserName}
conf: classpath:liquibase/master.xml
<#if bDynamicDS>
<@dynamicDatasourceConfig/>
<#else>
<@singleDatasourceConfig/>
</#if>
#Mybatis-plus配置
mybatis-plus:
...
...
@@ -234,3 +220,82 @@ server:
mime-types: application/javascript,text/css,application/json,application/xml,text/html,text/xml,text/plain
min-response-size: 10240
<#macro singleDatasourceConfig>
datasource:
username: ${dbUserName}
password: '${dbPassWord}'
url: ${dbUrl}
driver-class-name: ${dbDriver}
filters: stat,wall,log4j2
#配置初始化大小/最小/最大
initial-size: 1
min-idle: 1
max-active: 20
#获取连接等待超时时间
max-wait: 60000
#间隔多久进行一次检测,检测需要关闭的空闲连接
time-between-eviction-runs-millis: 60000
#一个连接在池中最小生存的时间
min-evictable-idle-time-millis: 300000
validation-query: SELECT 1 FROM DUAL
test-while-idle: true
test-on-borrow: false
test-on-return: false
#打开PSCache,并指定每个连接上PSCache的大小。oracle设为true,mysql设为false。分库分表较多推荐设置为false
pool-prepared-statements: false
max-pool-prepared-statement-per-connection-size: 20
isSyncDBSchema: false
defaultSchema: ${dbUserName}
conf: classpath:liquibase/master.xml
</#macro>
<#macro dynamicDatasourceConfig>
datasource:
dynamic:
druid: #以下是全局默认值,可以全局更改
filters: stat,wall,log4j2
#配置初始化大小/最小/最大
initial-size: 1
min-idle: 1
max-active: 20
#获取连接等待超时时间
max-wait: 60000
#间隔多久进行一次检测,检测需要关闭的空闲连接
time-between-eviction-runs-millis: 60000
#一个连接在池中最小生存的时间
min-evictable-idle-time-millis: 300000
validation-query: SELECT 1 FROM DUAL
test-while-idle: true
test-on-borrow: false
test-on-return: false
#打开PSCache,并指定每个连接上PSCache的大小。oracle设为true,mysql设为false。分库分表较多推荐设置为false
pool-prepared-statements: false
max-pool-prepared-statement-per-connection-size: 20
datasource:
master:
username: ${dbUserName}
password: '${dbPassWord}'
url: ${dbUrl}
driver-class-name: ${dbDriver}
conf: classpath:liquibase/master.xml
isSyncDBSchema: false
defaultSchema: ${dbUserName}
<#list sys.getAllPSDataEntities() as entity>
<#if (entity.getStorageMode()==1 || entity.getStorageMode()==2) && entity.getDSLink()!='DEFAULT'>
<#assign dbLink=entity.getDSLink()>
<#if !P.exists('dynamicDatasource',dbLink)>
${dbLink}:
username: ${dbUserName}
password: '${dbPassWord}'
url: ${dbUrl}
driver-class-name: ${dbDriver}
conf: classpath:liquibase/master.xml
isSyncDBSchema: false
defaultSchema: ${dbUserName}
</#if>
</#if>
</#list>
</#macro>
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录