Search code examples
javaibatis

How to use a file-resource instead of a classpath-resource in ibatis sqlMap config?


I'd like to use the same ibatis sqlMapConfig on many modules.

Unfortunatly only classpath-resources seems to be allowed in the resource-attribute of my sqlMap:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMapConfig PUBLIC "-//ibatis.apache.org//DTD SQL Map Config 2.0//EN"
"http://ibatis.apache.org/dtd/sql-map-config-2.dtd">
<sqlMapConfig>
    <sqlMap resource="myresource.xml" />
</sqlMapConfig>

This does not work:

    <sqlMap resource="file:/myresource.xml" />

Is there any way to avoid duplicity (using one ibatis-config on many classpathes)?


Solution

  • Use the url attribute :

    <sqlMap url="file:///myresource.xml" />