【问题标题】:How to use file.seperator in ibatis resource attribute of sql-map tag如何在sql-map标签的mybatis资源属性中使用file.separator
【发布时间】:2016-02-15 05:58:06
【问题描述】:

我正在使用 ibatis 对我的应用程序进行 OR 映射。我和我的团队正在开发两种不同的操作系统,系统是 UBUNTU 和 Windows xp。我有一个sqlmapconfig.xml 文件,我在其中引用了我的 ibatis 查询 xml 文件,我在其中编写了所有查询。

但是当我创建 sqlmapconfig 时,我想通过使用文件分隔符在 sql-map 标记的资源属性中给出我的 query.xml 的路径,以便它可以通过操作系统调整分隔符,因为我已经编写了如下代码sqlmapconfig.xml

<sqlMap 
      resource="file:com${file.separator}platysgroup${file.separator}lmexserver${file.separator}mobile${file.separator}dao${file.separator}ibatis{file.separator}lmexusermobileinfo.xml" />

但是当我运行我的应用程序时出现异常:

com.ibatis.common.xml.NodeletException:解析 XML 时出错。原因:java.lang.RuntimeException:解析 XPath '/sqlMapConfig/sqlMap' 时出错。原因:java.io.IOException:找不到资源文件:comfile.separatorplatysgroupfile.separatorlmexserverfile.separatormobilefile.separatordaofile.separatoribatis{file.separator}lmexusermobileinfo.xml`

如何解决这个问题?请帮帮我。

谢谢

【问题讨论】:

  • 很抱歉没有写代码,我完全想念它。我的 sqlmapconfig.xml 代码是:

标签: java ibatis


【解决方案1】:

错误“com.ibatis.common.xml.NodeletException:解析 XML 时出错。原因:java.lang.RuntimeException:解析 XPath '/sqlMapConfig/sqlMap' 时出错。原因:java.io.IOException:可能not find resource file:comfile.separatorplatysgroupfile.separatorlmexserverfile.separatormobilefile.separatordaofile.separatoribatis{file.separator}lmexusermobileinfo.xml表示请求的sqlMapConfig.xml没有放好,放在src文件夹下。检查您是否能够访问它。

【讨论】:

  • 当时我的 app-config.xml 遇到了同样的问题,我将 app-config.xml 移动到 src 文件夹,但它不起作用,然后我使用文件分隔符同时给出路径并且它有效,即我在 sqlmapconfig.xml 文件中做了同样的事情。所以当我们将它移动到 src 文件夹时它不起作用。请提供任何其他解决方案
  • 你能把app-config.xml的代码用文件分隔符贴出来吗,也许我们可以交叉检查两者是否相同。
  • 我的 app-config.xml 如下:
  • 正如你在上面的帖子中看到的,你已经给出了 src 下的路径,请给出 src 下的路径并尝试。它应该可以工作。!!!
猜你喜欢
  • 2020-05-15
  • 1970-01-01
  • 1970-01-01
  • 2017-10-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多