[英]Cannot find declaration to go to in maven?
org.apache.ibatis.exceptions.PersistenceException:
### Error building SqlSession.
### The error may exist in tk.mybatis.simple.mapper.CountryMapper.xml
### Cause: org.apache.ibatis.builder.BuilderException:
Error parsing SQL Mapper Configuration.
Cause: java.io.IOException:
Could not find resource tk.mybatis.simple.mapper.CountryMapper.xml
<mappers>
<mapper resource="tk.mybatis.simple.mapper.CountryMapper.xml"/>
</mappers>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
</resource>
</resources>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="tk.mybatis.simple.mapper.CountryMapper">
<select id="selectAll" resultType="Country">
select id,countryname,countrycode from country
</select>
</mapper>
mybatis-config.xml
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd"> <configuration> <settings> <setting name="logImpl" value="LOG4J"/> </settings> <typeAliases> <package name="tk.mybatis.simple.model"/> </typeAliases> <environments default="development"> <environment id="development"> <transactionManager type="JDBC"> <property name="" value=""/> </transactionManager> <dataSource type="UNPOOLED"> <property name="driver" value="com.mysql.jdbc.Driver"/> <property name="url" value="jdbc:mysql://localhost:3306/mybatis"/> <property name="username" value="root"/> <property name="password" value="12345"/> </dataSource> </environment> </environments> <mappers> <mapper resource="tk.mybatis.simple.mapper.CountryMapper.xml"/> </mappers> </configuration>
CountryMapper.xml
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > <mapper namespace="tk.mybatis.simple.mapper.CountryMapper"> <select id="selectAll" resultType="Country"> select id,countryname,countrycode from country </select> </mapper>
The mapper resource path should be separated by slash. 映射器资源路径应以斜杠分隔。
<mapper resource="tk/mybatis/simple/mapper/CountryMapper.xml"/>
http://www.mybatis.org/mybatis-3/configuration.html#mappers http://www.mybatis.org/mybatis-3/configuration.html#mappers
Because the optical package naming is the same in IntelliJ IDEA, the both are the tk.mybatis.simple.mapper
. 因为IntelliJ IDEA中的光学包装命名是相同的 ,所以两者都是
tk.mybatis.simple.mapper
。
Actually, correct path is tk/mybatis/simple/mapper
, error path is tk.mybatis.simple.mapper
. 实际上,正确的路径是
tk/mybatis/simple/mapper
,错误路径是tk.mybatis.simple.mapper
。
Please follow the below method to check it: 请按照以下方法进行检查:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.