使用代码生成器生成的代码,编译时maven排除了.xml文件,导致mapper.xml找不到


这种BindingException就是因为生成的target文件中找不到对应的mapper.xml文件导致

解决办法:
1.在pom.xml文件中加入

<build>
        <resources>
            <resource>
                <directory>src/main/java</directory>
                <includes>
                    <include>**/*.xml</include>
                </includes>
                <filtering>false</filtering>
            </resource>
        </resources>
    </build>

2.在application.yml中加入mapper.xml的位置

mybatis-plus:
  mapper-locations: classpath*:com/zyx/mall/mapper/**/*.xml
posted @ 2022-12-30 18:38  风一样的男子、  阅读(72)  评论(0)    收藏  举报