springBoot整合mybatis配置mapper xml问题


如果mapper没有在resource目录下需要在pom文件build标签中添加以下代码

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

该配置和配置文件中的(mapper-locations: classpath*:/com/mybatis/**/*Mapper.xml)必须同时存在

mybatis-plus:
  configuration:
    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
  mapper-locations: classpath*:/com/mybatis/**/*Mapper.xml

如果没有扫描到yml注意启动项目时打印的 ”Property 'mapperLocations' was not specified.”


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM