多数据源中,在的数据源配置里加上以下代码:
public SqlSessionFactory firstSqlSessionFactory(@Qualifier("firstDataSource") DataSource datasource) throws Exception { SqlSessionFactoryBean bean = new SqlSessionFactoryBean(); bean.setDataSource(datasource); //------------------------------------------------加入的代码开始------------------------------------------------ org.apache.ibatis.session.Configuration configuration = new org.apache.ibatis.session.Configuration(); configuration.setCallSettersOnNulls(true); bean.setConfiguration(configuration); //------------------------------------------------加入的代码结束------------------------------------------------ bean.setMapperLocations( // 设置mybatis的xml所在位置 new PathMatchingResourcePatternResolver().getResources("classpath*:mapper/first/*.xml")); return bean.getObject(); }
原文地址:https://www.cnblogs.com/zhengOK/p/10439232.html
时间: 2024-10-08 22:00:20