【问题标题】:Mybatis(iBatis) XML mapping configurationMybatis(iBatis) XML映射配置
【发布时间】:2013-11-01 15:36:07
【问题描述】:

我正在使用 MyBatis 3.2.2,但在将 XML 映射器作为资源加载时遇到问题。

<mappers>
    <mapper resource="src/main/resources/Conference.xml" />
</mappers>

异常

nested exception is org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: java.io.IOException: Could not find resource src/main/resources/Conference.xml

项目由 Maven 构建。

【问题讨论】:

  • 尝试自己指定包名,如果你的源文件夹是“src”,那就是main/resources/Conference.xml

标签: java spring maven spring-mvc mybatis


【解决方案1】:

您正在使用 Maven,因此您可以完全放弃 src/main/resources 路径,因为 Conference.xml 将在您的类路径的根目录中找到。这应该有效:

<mappers>
    <mapper resource="Conference.xml" />
</mappers>

【讨论】:

  • 因为我得到了异常解析 Conference.xml 所以我认为问题已经解决了。找到了资源。而mybatis-config.xml,以及所有的mappers xml配置都在同一个src/main/resources文件夹中。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2018-07-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2010-09-12
  • 1970-01-01
相关资源
最近更新 更多