Comments (1)
代码、ISSUE和REAMDE里面都有写,如果非要设置MapperLocation,就把@ConfigurationProperties(prefix = "mybatis")
删掉,同时设置MapperLocation
/**
* 配置 SqlSessionFactoryBean
* @ConfigurationProperties 在这里是为了将 MyBatis 的 mapper 位置和持久层接口的别名设置到
* Bean 的属性中,如果没有使用 *.xml 则可以不用该配置,否则将会产生 invalid bond statement 异常
*
* @return the sql session factory bean
*/
@Bean
@ConfigurationProperties(prefix = "mybatis")
public SqlSessionFactoryBean sqlSessionFactoryBean() {
SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
// 配置数据源,此处配置为关键配置,如果没有将 dynamicDataSource 作为数据源则不能实现切换
sqlSessionFactoryBean.setDataSource(dynamicDataSource());
return sqlSessionFactoryBean;
}
# MyBatis config
mybatis.type-aliases-package=cn.com.hellowood.dynamicdatasource.mapper
mybatis.mapper-locations=mappers/**Mapper.xml
from springboot-dynamicdatasource.
Related Issues (20)
- 在@Transactional的方法中切换数据源失败 HOT 1
- 测试数据的返回值 HOT 1
- 主从数据切换数据同步问题 HOT 2
- 没有注解实现切换吗 HOT 2
- Caused by: java.io.FileNotFoundException: class path resource [mapper/*.xml] cannot be opened because it does not exist HOT 1
- 关于切换不成功问题 HOT 3
- 关于动态增减数据源 HOT 1
- 能否通过数据库表的方式来配置多个数据源? HOT 8
- springboot2.0+版本无法切换slave数据源。 HOT 1
- 后期再追加多个数据库的问题 HOT 5
- 多类型数据源怎么配置方言呢
- java: 无法将类 java.lang.ThreadLocal<T>中的方法 withInitial应用到给定类型 HOT 1
- 按这种方式该怎么样实现事务呢 HOT 1
- 数据库上下文配置 HOT 1
- 在DAO上进行切片,没有办法切换数据库呀? 只能在servcie HOT 1
- spring mvc mybaits 怎样动态切换数据 HOT 1
- 配置文件关于mybatis配置问题
- where is the pom.xml HOT 2
- yml文件中配置mybatis.mapper-locations,启动报错 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from springboot-dynamicdatasource.