XLouis

博客园 首页 新随笔 联系 订阅 管理

问题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部分出现问题也可以使用相同的方法。

posted on 2023-05-24 19:35  XLouis  阅读(84)  评论(0编辑  收藏  举报