问题1:在mybatis-config.xml中使用了正确的资源路径,但是仍然报not find的错误!!!
<mappers> <mapper resource="com/louis/dao/UserMapper.xml"/> </mappers>
解决方法:①可以将资源放置在resource文件夹下
②在pom.xml中添加如下代码
<build> <finalName>mybatis-practise</finalName> <resources> <resource> <directory>src/main/resources</directory> <includes> <include>**/*.properties</include> <include>**/*.xml</include> </includes> <filtering>true</filtering> </resource> <resource> <directory>src/main/java</directory> <includes> <include>**/*.properties</include> <include>**/*.xml</include> </includes> <filtering>true</filtering> </resource> </resources> </build>
问题2:出现Java.lang.ClassNotFoundException: Cannot find class: ${com.mysql.cj.jdbc.Driver},可以将$和{}删除,同理username和password部分出现问题也可以使用相同的方法。
标签:xml,src,错误,properties,mybatis,true,find From: https://www.cnblogs.com/KhanLouis/p/17429320.html