[英]MyBatis can't load configuration xml situated in project resource folder
I am developing a java project with DB repositories and have faced with stupid question.我正在开发一个带有 DB 存储库的 Java 项目,但遇到了愚蠢的问题。 I use MySQL and Mybatis 3.4.5.我使用 MySQL 和 Mybatis 3.4.5。 The configuration file (mybatis-config.xml) situated in resources/mybatis folder.配置文件 (mybatis-config.xml) 位于 resources/mybatis 文件夹中。
I try to read it by the following code:我尝试通过以下代码读取它:
public class MySQLAttrRepo implements AttrRepo {
public static final String CONFIGURATION_XML = "mybatis/mybatis-config.xml";
private InputStream inputStream = Resources.getResourceAsStream(CONFIGURATION_XML);
}
but get an exception但得到一个例外
java.io.IOException: Could not find resource mybatis/mybatis-config.xml
What do I wrong?我怎么了?
Fixed.固定的。 The reason was wrong packaging in pom.xml.原因是 pom.xml 中的错误打包。 I set "pom" instead "jar".我设置了“pom”而不是“jar”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.