Is it possible to put myBatis (iBatis) xml mappers outside the project?

According to the user manual, I can use the file path instead of the resource:


// Using classpath relative resources
<mappers>
    <mapper resource="org/mybatis/builder/AuthorMapper.xml"/>
</mappers>

// Using url fully qualified paths
<mappers>
    <mapper url="file:///var/sqlmaps/AuthorMapper.xml"/>
</mappers>

in my project I am trying to put my xperter mapper outside the project and I am doing this:

<mapper url="file://D:/Mappers/ComponentMapper1.xml" /> 

The output of my log4j console is:

Error building SqlSession. 
The error may exist in file://D:/Mappers/ComponentMapper1.xml 
Cause: org.apache.ibatis.builder.BuilderException: Error parsing 
SQL Mapper Configuration. Cause: java.net.UnknownHostException: D 

Is this a mistake or am I doing something wrong?
+3
source share
3 answers

You will need an additional slash before the drive letter.

+1
source

Sql Map Config is looking for mapping files regarding the classpath, so just try adding your ComponentMapper1.xml somewhere in the classpath.

set CLASSPATH=%CLASSPATH%;D:/Mappers/

...

<mapper resource="ComponentMapper1.xml" />
0
source

<mapper url="file:///usr/local/ComponentMapper1.xml" />

file:///usr/local/ComponentMapper1.xml - XML , , mappers dir.

-1

Source: https://habr.com/ru/post/1749064/


All Articles