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