Skip to content

Caused by: java.io.FileNotFoundException: class path resource [mapper/*.xml] cannot be opened because it does not exist #16

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jiangxfsimon opened this issue Apr 7, 2020 · 1 comment

Comments

@jiangxfsimon
Copy link

我pull代码下来运行并且运行了,代码逻辑很清晰,而且代码精炼。但是发现了个小问题,始终会有找不到mapper/*.xml,下面是原来的配置。
@bean
@ConfigurationProperties(prefix = "mybatis")
public SqlSessionFactoryBean sqlSessionFactoryBean() {
...........
return sqlSessionFactoryBean;
}
在查看mybatis官网内容,其实不需要向spring容器中注入SqlSessionFactoryBean,只需要注入SqlSessionFactory就行,就不会有上面的问题了。截图是mybatis官网的解释(地址:http://mybatis.org/spring/zh/factorybean.html)。
5

@helloworlde
Copy link
Owner

MyBatis 文档描述的是使用默认配置的情况下不需要,但是,这里需要设置属性和数据源,是需要 SqlSessionFactoryBean来实现的,SqlSessionFactory不能设置相关属性
另外,找不到 xml,可以修改 DataSourceConfigurer.java#L118配置,可以看下方法的注释内容

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants