Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gjjs-bd-common
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
s_guodong
gjjs-bd-common
Commits
56ef0c88
Commit
56ef0c88
authored
Jan 11, 2023
by
lei wang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
多数据源适配:部分代码
parent
0241dac4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
191 additions
and
1 deletions
+191
-1
pom.xml
gjjs-bd-business/pom.xml
+5
-0
MyBatisDaoSession.java
...com/brilliance/mda/support/mybatis/MyBatisDaoSession.java
+0
-0
DbExecuteMapper.java
...ance/mda/support/mybatis/dync/mapper/DbExecuteMapper.java
+38
-0
DataSourceConfiguration.java
...java/com/ceb/gjjs/mda/config/DataSourceConfiguration.java
+45
-0
DataSourceConfiguration2.java
...ava/com/ceb/gjjs/mda/config/DataSourceConfiguration2.java
+54
-0
countermapper.xml
...ess/src/main/resources/META-INF/orm/mda/countermapper.xml
+25
-0
dbexecutemapper.xml
...s/src/main/resources/META-INF/orm/mda/dbexecutemapper.xml
+17
-0
application-oracle.yml
gjjs-bd-business/src/main/resources/application-oracle.yml
+6
-0
pom.xml
pom.xml
+1
-1
No files found.
gjjs-bd-business/pom.xml
View file @
56ef0c88
...
...
@@ -128,6 +128,11 @@
<artifactId>
ojdbc6
</artifactId>
<version>
12.1.0.2
</version>
</dependency>
<dependency>
<groupId>
mysql
</groupId>
<artifactId>
mysql-connector-java
</artifactId>
<version>
8.0.30
</version>
</dependency>
</dependencies>
...
...
gjjs-bd-business/src/main/java/com/brilliance/mda/support/mybatis/MyBatisDaoSession.java
0 → 100644
View file @
56ef0c88
This diff is collapsed.
Click to expand it.
gjjs-bd-business/src/main/java/com/brilliance/mda/support/mybatis/dync/mapper/DbExecuteMapper.java
0 → 100644
View file @
56ef0c88
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//
package
com
.
brilliance
.
mda
.
support
.
mybatis
.
dync
.
mapper
;
import
org.mybatis.spring.SqlSessionTemplate
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.Resource
;
import
java.util.List
;
import
java.util.Map
;
@Component
public
class
DbExecuteMapper
{
@Autowired
@Resource
(
name
=
"sqlSessionTemplate"
)
SqlSessionTemplate
sqlSessionTemplate
;
@Autowired
@Resource
(
name
=
"sqlSessionTemplate2"
)
SqlSessionTemplate
sqlSessionTemplate2
;
final
String
FNAME
=
this
.
getClass
().
getName
();
public
DbExecuteMapper
()
{
}
public
List
<
Map
<
String
,
Object
>>
dyncReadForMap
(
Map
<
String
,
Object
>
params
)
{
return
this
.
sqlSessionTemplate
.
selectList
(
this
.
FNAME
+
".dyncReadForMap"
,
params
);
}
public
int
dyncUpdateForMap
(
Map
<
String
,
Object
>
params
)
{
return
this
.
sqlSessionTemplate
.
update
(
this
.
FNAME
+
".dyncUpdateForMap"
,
params
);
}
}
gjjs-bd-business/src/main/java/com/ceb/gjjs/mda/config/DataSourceConfiguration.java
0 → 100644
View file @
56ef0c88
package
com
.
ceb
.
gjjs
.
mda
.
config
;
import
com.alibaba.druid.pool.DruidDataSource
;
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.beans.factory.annotation.Qualifier
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
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
;
import
javax.sql.DataSource
;
import
java.sql.SQLException
;
@Configuration
@MapperScan
(
basePackages
=
"com.ceb.gjjs.mda.dao"
,
sqlSessionTemplateRef
=
"sqlSessionTemplate"
)
public
class
DataSourceConfiguration
{
@Primary
@Bean
(
name
=
"dataSource"
)
@ConfigurationProperties
(
prefix
=
"spring.datasource.druid"
)
public
DataSource
getDataSource
()
throws
SQLException
{
return
new
DruidDataSource
();
}
@Bean
(
name
=
"sqlSessionFactory"
)
public
SqlSessionFactory
getSqlSessionFactory
(
@Qualifier
(
"dataSource"
)
DataSource
dataSource
)
throws
Exception
{
SqlSessionFactoryBean
sqlfb
=
new
SqlSessionFactoryBean
();
sqlfb
.
setDataSource
(
dataSource
);
// sqlfb.setConfigLocation(new ClassPathResource("mybatis-config.xml"));
sqlfb
.
setMapperLocations
(
new
PathMatchingResourcePatternResolver
().
getResources
(
"classpath:META-INF/orm/mda/*.xml"
));
return
sqlfb
.
getObject
();
}
@Bean
(
name
=
"transactionManager"
)
public
DataSourceTransactionManager
getTransactionManager
(
@Qualifier
(
"dataSource"
)
DataSource
dataSource
)
{
return
new
DataSourceTransactionManager
(
dataSource
);
}
@Bean
(
name
=
"sqlSessionTemplate"
)
public
SqlSessionTemplate
getSqlSessionTemplate
(
@Qualifier
(
"sqlSessionFactory"
)
SqlSessionFactory
sqlSessionFactory
)
throws
Exception
{
return
new
SqlSessionTemplate
(
sqlSessionFactory
);
}
}
\ No newline at end of file
gjjs-bd-business/src/main/java/com/ceb/gjjs/mda/config/DataSourceConfiguration2.java
0 → 100644
View file @
56ef0c88
package
com
.
ceb
.
gjjs
.
mda
.
config
;
import
com.alibaba.druid.pool.DruidDataSource
;
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.beans.factory.annotation.Qualifier
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
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
;
import
javax.sql.DataSource
;
import
java.sql.SQLException
;
@Configuration
@MapperScan
(
basePackages
=
"com.ceb.gjjs.mda.dao"
,
sqlSessionTemplateRef
=
"sqlSessionTemplate2"
)
public
class
DataSourceConfiguration2
{
@Bean
(
name
=
"dataSource2"
)
@ConfigurationProperties
(
prefix
=
"spring.datasource2"
)
public
DataSource
getDataSource
()
throws
SQLException
{
return
new
DruidDataSource
();
}
@Bean
(
name
=
"sqlSessionFactory2"
)
@Primary
public
SqlSessionFactory
getSqlSessionFactory
(
@Qualifier
(
"dataSource2"
)
DataSource
dataSource
)
throws
Exception
{
SqlSessionFactoryBean
sqlfb
=
new
SqlSessionFactoryBean
();
sqlfb
.
setDataSource
(
dataSource
);
// sqlfb.setConfigLocation(new ClassPathResource("mybatis-config.xml"));
sqlfb
.
setMapperLocations
(
new
PathMatchingResourcePatternResolver
().
getResources
(
"classpath:META-INF/orm/mda/*.xml"
));
return
sqlfb
.
getObject
();
}
@Bean
(
name
=
"transactionManager2"
)
@Primary
public
DataSourceTransactionManager
getTransactionManager
(
@Qualifier
(
"dataSource2"
)
DataSource
dataSource
)
{
return
new
DataSourceTransactionManager
(
dataSource
);
}
@Bean
(
name
=
"sqlSessionTemplate2"
)
@Primary
public
SqlSessionTemplate
getSqlSessionTemplate
(
@Qualifier
(
"sqlSessionFactory2"
)
SqlSessionFactory
sqlSessionFactory
)
throws
Exception
{
return
new
SqlSessionTemplate
(
sqlSessionFactory
);
}
}
\ No newline at end of file
gjjs-bd-business/src/main/resources/META-INF/orm/mda/countermapper.xml
0 → 100644
View file @
56ef0c88
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"com.brilliance.mda.support.mybatis.count.mapper.CounterMapper"
>
<insert
id=
"insertNewCounter"
>
insert into COU(COUNAM,COUVAL,COUSTP) values(#{nam},#{start},#{stp})
</insert>
<select
id=
"getCountValWithUpdate"
resultType=
"java.lang.Integer"
>
select COUVAL from COU where COUNAM = #{nam} for update
</select>
<update
id=
"updateCounter"
>
update COU set COUVAL = COUVAL + COUSTP where COUNAM = #{nam}
</update>
<select
id=
"seqNextval"
resultType=
"java.lang.Integer"
>
select ${value}.nextval from dual
</select>
<select
id=
"dbCounter"
resultType=
"java.lang.Integer"
>
select f_dbcounter(#{seqName}) from dual;
</select>
</mapper>
\ No newline at end of file
gjjs-bd-business/src/main/resources/META-INF/orm/mda/dbexecutemapper.xml
0 → 100644
View file @
56ef0c88
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"com.brilliance.mda.support.mybatis.dync.mapper.DbExecuteMapper"
>
<select
id=
"dyncReadForMap"
resultType=
"java.util.LinkedHashMap"
>
${sql}
</select>
<update
id=
"dyncUpdateForMap"
>
${sql}
</update>
<select
id=
"dbDate"
resultType=
"java.util.Date"
>
select sysdate from dual
</select>
</mapper>
\ No newline at end of file
gjjs-bd-business/src/main/resources/application-oracle.yml
View file @
56ef0c88
...
...
@@ -44,6 +44,12 @@ spring:
port
:
6379
password
:
datasource2
:
url
:
jdbc:mysql://localhost:3306/cfix?serverTimezone=UTC&useUnicode=true&characterEncoding=utf8&useSSL=false
username
:
root
password
:
123456
driver-class-name
:
com.mysql.cj.jdbc.Driver
envConfig
:
rootPath
:
workRoot
...
...
pom.xml
View file @
56ef0c88
...
...
@@ -32,7 +32,7 @@
<itext-asian.version>
5.2.0
</itext-asian.version>
<xmlworker.version>
5.5.8
</xmlworker.version>
<mybatis.spring.boot.starter.version>
2.1.4
</mybatis.spring.boot.starter.version>
<mysql.connector.java.version>
5.1
.29
</mysql.connector.java.version>
<mysql.connector.java.version>
8.0
.29
</mysql.connector.java.version>
<poi.ooxml.version>
4.1.0
</poi.ooxml.version>
<commons.io.version>
2.6
</commons.io.version>
<commons.codec.version>
1.10
</commons.codec.version>
...
...
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