forked from zhoustone/middle-ware-parent
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
cicadasmile
committed
Oct 11, 2019
1 parent
eac2c5c
commit 8bb17e7
Showing
22 changed files
with
2,948 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<?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" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starters</artifactId> | ||
<version>2.1.3.RELEASE</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>com.source.data</groupId> | ||
<artifactId>ware-source-data</artifactId> | ||
<packaging>jar</packaging> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-web</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-aop</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-test</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.mybatis.spring.boot</groupId> | ||
<artifactId>mybatis-spring-boot-starter</artifactId> | ||
<version>1.3.2</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>mysql</groupId> | ||
<artifactId>mysql-connector-java</artifactId> | ||
<version>5.1.38</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.alibaba</groupId> | ||
<artifactId>druid-spring-boot-starter</artifactId> | ||
<version>1.1.13</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>commons-lang</groupId> | ||
<artifactId>commons-lang</artifactId> | ||
<version>2.6</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
<!-- 项目构建 --> | ||
<build> | ||
<finalName>${project.artifactId}</finalName> | ||
<resources> | ||
<resource> | ||
<directory>src/main/java</directory> | ||
<includes> | ||
<include>**/*.xml</include> | ||
</includes> | ||
<filtering>false</filtering> | ||
</resource> | ||
</resources> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>2.3.2</version> | ||
<configuration> | ||
<source>1.8</source> | ||
<target>1.8</target> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
11 changes: 11 additions & 0 deletions
11
ware-source-data/src/main/java/com/data/source/Application7013.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.data.source; | ||
|
||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
|
||
@SpringBootApplication | ||
public class Application7013 { | ||
public static void main(String[] args) { | ||
SpringApplication.run(Application7013.class,args) ; | ||
} | ||
} |
75 changes: 75 additions & 0 deletions
75
ware-source-data/src/main/java/com/data/source/config/DruidOneConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package com.data.source.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.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.core.io.support.PathMatchingResourcePatternResolver; | ||
import org.springframework.core.io.support.ResourcePatternResolver; | ||
import org.springframework.jdbc.datasource.DataSourceTransactionManager; | ||
import javax.annotation.Resource; | ||
import javax.sql.DataSource; | ||
|
||
@Configuration | ||
@MapperScan(basePackages = {"com.data.source.mapper.one"},sqlSessionTemplateRef = "sqlSessionTemplateOne") | ||
public class DruidOneConfig { | ||
|
||
private static final Logger LOGGER = LoggerFactory.getLogger(DruidOneConfig.class) ; | ||
|
||
@Resource | ||
private DruidOneParam druidOneParam ; | ||
|
||
@Bean("dataSourceOne") | ||
public DataSource dataSourceOne () { | ||
DruidDataSource datasource = new DruidDataSource(); | ||
datasource.setUrl(druidOneParam.getDbUrl()); | ||
datasource.setUsername(druidOneParam.getUsername()); | ||
datasource.setPassword(druidOneParam.getPassword()); | ||
datasource.setDriverClassName(druidOneParam.getDriverClassName()); | ||
datasource.setInitialSize(druidOneParam.getInitialSize()); | ||
datasource.setMinIdle(druidOneParam.getMinIdle()); | ||
datasource.setMaxActive(druidOneParam.getMaxActive()); | ||
datasource.setMaxWait(druidOneParam.getMaxWait()); | ||
datasource.setTimeBetweenEvictionRunsMillis(druidOneParam.getTimeBetweenEvictionRunsMillis()); | ||
datasource.setMinEvictableIdleTimeMillis(druidOneParam.getMinEvictableIdleTimeMillis()); | ||
datasource.setMaxEvictableIdleTimeMillis(druidOneParam.getMaxEvictableIdleTimeMillis()); | ||
datasource.setValidationQuery(druidOneParam.getValidationQuery()); | ||
datasource.setTestWhileIdle(druidOneParam.isTestWhileIdle()); | ||
datasource.setTestOnBorrow(druidOneParam.isTestOnBorrow()); | ||
datasource.setTestOnReturn(druidOneParam.isTestOnReturn()); | ||
datasource.setPoolPreparedStatements(druidOneParam.isPoolPreparedStatements()); | ||
datasource.setMaxPoolPreparedStatementPerConnectionSize(druidOneParam.getMaxPoolPreparedStatementPerConnectionSize()); | ||
try { | ||
datasource.setFilters(druidOneParam.getFilters()); | ||
} catch (Exception e) { | ||
LOGGER.error("druid configuration initialization filter", e); | ||
} | ||
datasource.setConnectionProperties(druidOneParam.getConnectionProperties()); | ||
return datasource; | ||
} | ||
|
||
@Bean | ||
public SqlSessionFactory sqlSessionFactoryOne() throws Exception{ | ||
SqlSessionFactoryBean factory = new SqlSessionFactoryBean(); | ||
ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(); | ||
factory.setDataSource(dataSourceOne()); | ||
factory.setMapperLocations(resolver.getResources("classpath*:/dataOneMapper/*.xml")); | ||
return factory.getObject(); | ||
} | ||
|
||
@Bean(name="transactionManagerOne") | ||
public DataSourceTransactionManager transactionManagerOne(){ | ||
return new DataSourceTransactionManager(dataSourceOne()); | ||
} | ||
|
||
@Bean(name = "sqlSessionTemplateOne") | ||
public SqlSessionTemplate sqlSessionTemplateOne() throws Exception { | ||
return new SqlSessionTemplate(sqlSessionFactoryOne()); | ||
} | ||
|
||
} |
180 changes: 180 additions & 0 deletions
180
ware-source-data/src/main/java/com/data/source/config/DruidOneParam.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,180 @@ | ||
package com.data.source.config; | ||
|
||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
@ConfigurationProperties(prefix = "spring.datasource.admin-data") | ||
public class DruidOneParam { | ||
private String dbUrl; | ||
private String username; | ||
private String password; | ||
private String driverClassName; | ||
private int initialSize; | ||
private int maxActive; | ||
private int minIdle; | ||
private int maxWait; | ||
private boolean poolPreparedStatements; | ||
private int maxPoolPreparedStatementPerConnectionSize; | ||
private int timeBetweenEvictionRunsMillis; | ||
private int minEvictableIdleTimeMillis; | ||
private int maxEvictableIdleTimeMillis; | ||
private String validationQuery; | ||
private boolean testWhileIdle; | ||
private boolean testOnBorrow; | ||
private boolean testOnReturn; | ||
private String filters; | ||
private String connectionProperties; | ||
|
||
public String getDbUrl() { | ||
return dbUrl; | ||
} | ||
|
||
public void setDbUrl(String dbUrl) { | ||
this.dbUrl = dbUrl; | ||
} | ||
|
||
public String getUsername() { | ||
return username; | ||
} | ||
|
||
public void setUsername(String username) { | ||
this.username = username; | ||
} | ||
|
||
public String getPassword() { | ||
return password; | ||
} | ||
|
||
public void setPassword(String password) { | ||
this.password = password; | ||
} | ||
|
||
public String getDriverClassName() { | ||
return driverClassName; | ||
} | ||
|
||
public void setDriverClassName(String driverClassName) { | ||
this.driverClassName = driverClassName; | ||
} | ||
|
||
public int getInitialSize() { | ||
return initialSize; | ||
} | ||
|
||
public void setInitialSize(int initialSize) { | ||
this.initialSize = initialSize; | ||
} | ||
|
||
public int getMaxActive() { | ||
return maxActive; | ||
} | ||
|
||
public void setMaxActive(int maxActive) { | ||
this.maxActive = maxActive; | ||
} | ||
|
||
public int getMinIdle() { | ||
return minIdle; | ||
} | ||
|
||
public void setMinIdle(int minIdle) { | ||
this.minIdle = minIdle; | ||
} | ||
|
||
public int getMaxWait() { | ||
return maxWait; | ||
} | ||
|
||
public void setMaxWait(int maxWait) { | ||
this.maxWait = maxWait; | ||
} | ||
|
||
public boolean isPoolPreparedStatements() { | ||
return poolPreparedStatements; | ||
} | ||
|
||
public void setPoolPreparedStatements(boolean poolPreparedStatements) { | ||
this.poolPreparedStatements = poolPreparedStatements; | ||
} | ||
|
||
public int getMaxPoolPreparedStatementPerConnectionSize() { | ||
return maxPoolPreparedStatementPerConnectionSize; | ||
} | ||
|
||
public void setMaxPoolPreparedStatementPerConnectionSize(int maxPoolPreparedStatementPerConnectionSize) { | ||
this.maxPoolPreparedStatementPerConnectionSize = maxPoolPreparedStatementPerConnectionSize; | ||
} | ||
|
||
public int getTimeBetweenEvictionRunsMillis() { | ||
return timeBetweenEvictionRunsMillis; | ||
} | ||
|
||
public void setTimeBetweenEvictionRunsMillis(int timeBetweenEvictionRunsMillis) { | ||
this.timeBetweenEvictionRunsMillis = timeBetweenEvictionRunsMillis; | ||
} | ||
|
||
public int getMinEvictableIdleTimeMillis() { | ||
return minEvictableIdleTimeMillis; | ||
} | ||
|
||
public void setMinEvictableIdleTimeMillis(int minEvictableIdleTimeMillis) { | ||
this.minEvictableIdleTimeMillis = minEvictableIdleTimeMillis; | ||
} | ||
|
||
public int getMaxEvictableIdleTimeMillis() { | ||
return maxEvictableIdleTimeMillis; | ||
} | ||
|
||
public void setMaxEvictableIdleTimeMillis(int maxEvictableIdleTimeMillis) { | ||
this.maxEvictableIdleTimeMillis = maxEvictableIdleTimeMillis; | ||
} | ||
|
||
public String getValidationQuery() { | ||
return validationQuery; | ||
} | ||
|
||
public void setValidationQuery(String validationQuery) { | ||
this.validationQuery = validationQuery; | ||
} | ||
|
||
public boolean isTestWhileIdle() { | ||
return testWhileIdle; | ||
} | ||
|
||
public void setTestWhileIdle(boolean testWhileIdle) { | ||
this.testWhileIdle = testWhileIdle; | ||
} | ||
|
||
public boolean isTestOnBorrow() { | ||
return testOnBorrow; | ||
} | ||
|
||
public void setTestOnBorrow(boolean testOnBorrow) { | ||
this.testOnBorrow = testOnBorrow; | ||
} | ||
|
||
public boolean isTestOnReturn() { | ||
return testOnReturn; | ||
} | ||
|
||
public void setTestOnReturn(boolean testOnReturn) { | ||
this.testOnReturn = testOnReturn; | ||
} | ||
|
||
public String getFilters() { | ||
return filters; | ||
} | ||
|
||
public void setFilters(String filters) { | ||
this.filters = filters; | ||
} | ||
|
||
public String getConnectionProperties() { | ||
return connectionProperties; | ||
} | ||
|
||
public void setConnectionProperties(String connectionProperties) { | ||
this.connectionProperties = connectionProperties; | ||
} | ||
} |
Oops, something went wrong.