package com.newfiber.api.config; import com.alibaba.druid.pool.DruidDataSource; import org.apache.ibatis.session.SqlSession; 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.boot.jdbc.DataSourceBuilder; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Primary; import org.springframework.jdbc.datasource.DataSourceTransactionManager; import org.springframework.transaction.PlatformTransactionManager; import javax.sql.DataSource; /** * 数据源配置 * @author hy */ //@Configuration public class DataSourceConfig { @ConfigurationProperties(prefix = "spring.datasource") @Bean(name="datasource",initMethod = "init",destroyMethod = "close") public DruidDataSource getDataSource(){ return new DruidDataSource(); } @Bean public PlatformTransactionManager transactionManager(){ return new DataSourceTransactionManager(getDataSource()); } }