Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
I
indicators
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
zhangkb
indicators
Commits
6e73a34f
Commit
6e73a34f
authored
Apr 14, 2020
by
张祺
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
去除第二数据源,修改mapper配置
parent
22e16976
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
8 additions
and
51 deletions
+8
-51
pom.xml
pom.xml
+4
-1
SecondDatasourceConf.java
...a/com/keymobile/indicators/conf/SecondDatasourceConf.java
+0
-44
T1Mapper.java
.../java/com/keymobile/indicators/model/mapper/T1Mapper.java
+2
-1
application-test.yml
src/main/resources/application-test.yml
+2
-5
No files found.
pom.xml
View file @
6e73a34f
...
...
@@ -32,7 +32,10 @@
<artifactId>
spring-cloud-starter-netflix-eureka-client
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<groupId>
org.springframework.boot
</groupId>
t
<artifactId>
spring-boot-starter-test
</artifactId>
<scope>
test
</scope>
</dependency>
...
...
src/main/java/com/keymobile/indicators/conf/SecondDatasourceConf.java
deleted
100644 → 0
View file @
22e16976
package
com
.
keymobile
.
indicators
.
conf
;
import
javax.sql.DataSource
;
import
org.apache.ibatis.session.SqlSessionFactory
;
import
org.mybatis.spring.SqlSessionFactoryBean
;
import
org.mybatis.spring.SqlSessionTemplate
;
import
org.mybatis.spring.annotation.MapperScan
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.boot.jdbc.DataSourceBuilder
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Primary
;
import
org.springframework.core.io.support.PathMatchingResourcePatternResolver
;
import
org.springframework.jdbc.datasource.DataSourceTransactionManager
;
@Configuration
@MapperScan
(
basePackages
=
"com.keymobile.indicators.model.mapper"
,
sqlSessionTemplateRef
=
"secondSqlSessionTemplate"
)
public
class
SecondDatasourceConf
{
@Primary
//指定主库
@Bean
@ConfigurationProperties
(
prefix
=
"spring.datasource.second"
)
public
DataSource
secondDatasource
()
{
return
DataSourceBuilder
.
create
().
build
();
}
@Bean
public
SqlSessionFactory
secondSqlSessionFactory
()
throws
Exception
{
SqlSessionFactoryBean
sqlSessionFactoryBean
=
new
SqlSessionFactoryBean
();
sqlSessionFactoryBean
.
setDataSource
(
secondDatasource
());
sqlSessionFactoryBean
.
setMapperLocations
(
new
PathMatchingResourcePatternResolver
().
getResources
(
"classpath:mybatis/mapping/*Mapper.xml"
));
return
sqlSessionFactoryBean
.
getObject
();
}
@Bean
public
DataSourceTransactionManager
secondTxMananger
()
{
return
new
DataSourceTransactionManager
(
secondDatasource
());
}
@Bean
public
SqlSessionTemplate
secondSqlSessionTemplate
()
throws
Exception
{
return
new
SqlSessionTemplate
(
secondSqlSessionFactory
());
}
}
src/main/java/com/keymobile/indicators/model/mapper/T1Mapper.java
View file @
6e73a34f
...
...
@@ -2,11 +2,12 @@ package com.keymobile.indicators.model.mapper;
import
java.util.List
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.springframework.stereotype.Repository
;
import
com.keymobile.indicators.model.entity.T1
;
@
Repository
@
Mapper
public
interface
T1Mapper
{
List
<
T1
>
selAll
();
}
src/main/resources/application-test.yml
View file @
6e73a34f
...
...
@@ -17,11 +17,6 @@ spring:
password
:
test
hikari
:
maximum-pool-size
:
3
second
:
driverClassName
:
com.mysql.jdbc.Driver
jdbcUrl
:
jdbc:mysql://139.198.127.54:9306/dev0?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8
username
:
test
password
:
test
servlet
:
multipart
:
max-file-size
:
20Mb
...
...
@@ -54,4 +49,5 @@ security:
authPwd
:
pwd
mybatis
:
mapper-locations
:
classpath:/mybatis/mapping/*.xml
type-aliases-package
:
com.keymobile.indicators.model.entity
\ No newline at end of file
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