debug
This commit is contained in:
@ -8,9 +8,8 @@ import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
|
||||
import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure;
|
||||
|
||||
@SpringBootApplication(exclude = { DruidDataSourceAutoConfigure.class, DataSourceAutoConfiguration.class })
|
||||
//@SpringBootApplication(exclude = { DruidDataSourceAutoConfigure.class, DataSourceAutoConfiguration.class })
|
||||
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })
|
||||
@EnableFeignClients
|
||||
@EnableEurekaClient
|
||||
@MapperScan({ "com.chinaunicom.mall.ebtp.project.**.dao" })
|
||||
|
@ -0,0 +1,43 @@
|
||||
package com.chinaunicom.mall.ebtp.project.config;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
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 com.alibaba.druid.pool.DruidDataSource;
|
||||
|
||||
import io.seata.rm.datasource.DataSourceProxy;
|
||||
|
||||
@Configuration
|
||||
public class DataSourceConfig {
|
||||
|
||||
@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*:com/chinaunicom/mall/ebtp/**/mapper/*Mapper.xml"));
|
||||
sqlSessionFactoryBean.setTransactionFactory(new SpringManagedTransactionFactory());
|
||||
return sqlSessionFactoryBean.getObject();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user