Hello all,
Package scanning seems to be skipping mapper files packaged in a jar file. I'm not using Spring-Boot; it's just a straight-up export-as-jar from Eclipse.
For example:
<mappers>
<!-- Doesn't work when I package my app as a single JAR. -->
<package name="testmy.sqlmaps" />
<!-- Works even when mapper files are in a JAR file. -->
<!--mapper class="testmy.sqlmaps.TestMyMapper" /-->
</mappers>
Things work properly when I run my project via Eclipse or via command line as an "exploded jar", but if I run my app via command line packaged in a jar file then I get the following stack trace:
org.apache.ibatis.binding.BindingException: Type interface testmy.sqlmaps.TestMyMapper is not known to the MapperRegistry.
at org.apache.ibatis.binding.MapperRegistry.getMapper(MapperRegistry.java:47)
at org.apache.ibatis.session.Configuration.getMapper(Configuration.java:675)
at org.apache.ibatis.session.defaults.DefaultSqlSession.getMapper(DefaultSqlSession.java:250)
at testmy.dao.TestMyDAO.testMyBatisQuery(TestMyDAO.java:9)
at testmy.batch.TestMybatis.main(TestMybatis.java:17)
It's as if ResolverUtil
is either skipping my application jar or doesn't know to look inside for goodies.
I'm running Mybatis v3.3.0. Also, attached is a single file containing relevant source file contents, which is as distilled as I can muster.
Any ideas?
C:/test/testMyBatisBatch/My mapper XML files are inside MybatisCommandLine.jar, as is the main class invoked by RunTest.bat.
- lib/
- various third-party jars are here
- MybatisCommandLine.jar
- RunTest.bat
-- -- TestMyMapper.xml -- <?xml version="1.0" encoding="UTF-8" standalone="no"?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="testmy.sqlmaps.TestMyMapper"> <select id="testMyBatisQuery" resultType="string"> SELECT 'Testing' FROM SYSIBM.SYSDUMMY1 </select> </mapper>