这是数据链接方面的配置
package cn.com.somuns.config;
import com.alibaba.druid.pool.DruidDataSource;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import javax.sql.DataSource;
@Configuration
//扫描mapper接口管理
@MapperScan(basePackages = "cn.com.somuns.dao.two",sqlSessionFactoryRef = "twoSqlSessionFactory")
public class DataSourceConfigTwo {
//注入连接信息
@Bean("twoDataSource")
@ConfigurationProperties(prefix = "two.datasource")
public DataSource twoDataSource(){
return DataSourceBuilder.create().build();
}
//创建数据源事务管理
@Bean(name = "twoTransactionManager")
public DataSourceTransactionManager twoTransactionManager(){
//注入数据源
return new DataSourceTransactionManager(twoDataSource());
}
@Bean(name = "twoSqlSessionFactory")
public SqlSessionFactory twoSqlSessionFactory(@Qualifier("twoDataSource") DataSource twoDataSource)throws Exception{//注入数据源创建sql工厂
final SqlSessionFactoryBean sqlSessionFactory = new SqlSessionFactoryBean();
sqlSessionFactory.setDataSource(twoDataSource);
sqlSessionFactory.setMapperLocations(new PathMatchingResourcePatternResolver().getResources("classpath:mapper/two/*.xml"));//扫描实体类映射文件
return sqlSessionFactory.getObject();
}
}
实体类有映射文件,dao接口,会由mybatis自动实现。现在怎么将这些东西替换成nutz