-
Notifications
You must be signed in to change notification settings - Fork 30
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
Showing
11 changed files
with
212 additions
and
20 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
60 changes: 60 additions & 0 deletions
60
...rring-member-service/src/main/java/com/herring/member/config/DataSourceConfiguration.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,60 @@ | ||
package com.herring.member.config; | ||
|
||
/* | ||
@(#)herring 2021-02-20 | ||
Copyright (c) 2011-2021 杭州湖畔网络技术有限公司 | ||
保留所有权利 | ||
本软件为杭州湖畔网络技术有限公司所有及包含机密信息,须遵守其相关许可证条款进行使用。 | ||
Copyright (c) 2011-2021 HUPUN Network Technology CO.,LTD. | ||
All rights reserved. | ||
This software is the confidential and proprietary information of HUPUN | ||
Network Technology CO.,LTD("Confidential Information"). You shall not | ||
disclose such Confidential Information and shall use it only in | ||
accordance with the terms of the license agreement you entered into with HUPUN. | ||
Website:http://www.hupun.com | ||
*/ | ||
|
||
import com.alibaba.druid.pool.DruidDataSource; | ||
import io.seata.rm.datasource.DataSourceProxy; | ||
import org.apache.ibatis.session.SqlSessionFactory; | ||
import org.mybatis.spring.SqlSessionFactoryBean; | ||
import org.mybatis.spring.transaction.SpringManagedTransactionFactory; | ||
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 javax.sql.DataSource; | ||
|
||
/** | ||
* @author: Jackey 2021/2/20 | ||
*/ | ||
@Configuration | ||
public class DataSourceConfiguration { | ||
|
||
@Bean | ||
@ConfigurationProperties(prefix = "spring.datasource") | ||
public DataSource druidDataSource() { | ||
DruidDataSource druidDataSource = new DruidDataSource(); | ||
return druidDataSource; | ||
} | ||
|
||
@Primary | ||
@Bean("dataSource") | ||
public DataSourceProxy dataSource(DataSource druidDataSource) { | ||
return new DataSourceProxy(druidDataSource); | ||
} | ||
|
||
@Bean | ||
public SqlSessionFactory sqlSessionFactory(DataSourceProxy dataSourceProxy) throws Exception { | ||
SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean(); | ||
sqlSessionFactoryBean.setDataSource(dataSourceProxy); | ||
sqlSessionFactoryBean.setMapperLocations(new PathMatchingResourcePatternResolver() | ||
.getResources("classpath*:/mapper/*.xml")); | ||
sqlSessionFactoryBean.setTransactionFactory(new SpringManagedTransactionFactory()); | ||
return sqlSessionFactoryBean.getObject(); | ||
} | ||
|
||
} |
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
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
60 changes: 60 additions & 0 deletions
60
...rring-orders-service/src/main/java/com/herring/orders/config/DataSourceConfiguration.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,60 @@ | ||
package com.herring.orders.config; | ||
|
||
/* | ||
@(#)herring 2021-02-20 | ||
Copyright (c) 2011-2021 杭州湖畔网络技术有限公司 | ||
保留所有权利 | ||
本软件为杭州湖畔网络技术有限公司所有及包含机密信息,须遵守其相关许可证条款进行使用。 | ||
Copyright (c) 2011-2021 HUPUN Network Technology CO.,LTD. | ||
All rights reserved. | ||
This software is the confidential and proprietary information of HUPUN | ||
Network Technology CO.,LTD("Confidential Information"). You shall not | ||
disclose such Confidential Information and shall use it only in | ||
accordance with the terms of the license agreement you entered into with HUPUN. | ||
Website:http://www.hupun.com | ||
*/ | ||
|
||
import com.alibaba.druid.pool.DruidDataSource; | ||
import io.seata.rm.datasource.DataSourceProxy; | ||
import org.apache.ibatis.session.SqlSessionFactory; | ||
import org.mybatis.spring.SqlSessionFactoryBean; | ||
import org.mybatis.spring.transaction.SpringManagedTransactionFactory; | ||
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 javax.sql.DataSource; | ||
|
||
/** | ||
* @author: Jackey 2021/2/20 | ||
*/ | ||
@Configuration | ||
public class DataSourceConfiguration { | ||
|
||
@Bean | ||
@ConfigurationProperties(prefix = "spring.datasource") | ||
public DataSource druidDataSource() { | ||
DruidDataSource druidDataSource = new DruidDataSource(); | ||
return druidDataSource; | ||
} | ||
|
||
@Primary | ||
@Bean("dataSource") | ||
public DataSourceProxy dataSource(DataSource druidDataSource) { | ||
return new DataSourceProxy(druidDataSource); | ||
} | ||
|
||
@Bean | ||
public SqlSessionFactory sqlSessionFactory(DataSourceProxy dataSourceProxy) throws Exception { | ||
SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean(); | ||
sqlSessionFactoryBean.setDataSource(dataSourceProxy); | ||
sqlSessionFactoryBean.setMapperLocations(new PathMatchingResourcePatternResolver() | ||
.getResources("classpath*:/mapper/*.xml")); | ||
sqlSessionFactoryBean.setTransactionFactory(new SpringManagedTransactionFactory()); | ||
return sqlSessionFactoryBean.getObject(); | ||
} | ||
|
||
} |
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
60 changes: 60 additions & 0 deletions
60
...ing-product-service/src/main/java/com/herring/product/config/DataSourceConfiguration.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,60 @@ | ||
package com.herring.product.config; | ||
|
||
/* | ||
@(#)herring 2021-02-20 | ||
Copyright (c) 2011-2021 杭州湖畔网络技术有限公司 | ||
保留所有权利 | ||
本软件为杭州湖畔网络技术有限公司所有及包含机密信息,须遵守其相关许可证条款进行使用。 | ||
Copyright (c) 2011-2021 HUPUN Network Technology CO.,LTD. | ||
All rights reserved. | ||
This software is the confidential and proprietary information of HUPUN | ||
Network Technology CO.,LTD("Confidential Information"). You shall not | ||
disclose such Confidential Information and shall use it only in | ||
accordance with the terms of the license agreement you entered into with HUPUN. | ||
Website:http://www.hupun.com | ||
*/ | ||
|
||
import com.alibaba.druid.pool.DruidDataSource; | ||
import io.seata.rm.datasource.DataSourceProxy; | ||
import org.apache.ibatis.session.SqlSessionFactory; | ||
import org.mybatis.spring.SqlSessionFactoryBean; | ||
import org.mybatis.spring.transaction.SpringManagedTransactionFactory; | ||
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 javax.sql.DataSource; | ||
|
||
/** | ||
* @author: Jackey 2021/2/20 | ||
*/ | ||
@Configuration | ||
public class DataSourceConfiguration { | ||
|
||
@Bean | ||
@ConfigurationProperties(prefix = "spring.datasource") | ||
public DataSource druidDataSource() { | ||
DruidDataSource druidDataSource = new DruidDataSource(); | ||
return druidDataSource; | ||
} | ||
|
||
@Primary | ||
@Bean("dataSource") | ||
public DataSourceProxy dataSource(DataSource druidDataSource) { | ||
return new DataSourceProxy(druidDataSource); | ||
} | ||
|
||
@Bean | ||
public SqlSessionFactory sqlSessionFactory(DataSourceProxy dataSourceProxy) throws Exception { | ||
SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean(); | ||
sqlSessionFactoryBean.setDataSource(dataSourceProxy); | ||
sqlSessionFactoryBean.setMapperLocations(new PathMatchingResourcePatternResolver() | ||
.getResources("classpath*:/mapper/*.xml")); | ||
sqlSessionFactoryBean.setTransactionFactory(new SpringManagedTransactionFactory()); | ||
return sqlSessionFactoryBean.getObject(); | ||
} | ||
|
||
} |
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