记录一下springboot+mybatisplus项目启动时遇到Property ‘mapperLocations’ was not specified的解决方法。
两步解决:
第一步,在pom.xml中添加如下代码

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

第二步,在yml配置文件中加上如下配置:

mybatis-plus:
  configuration:
    #控制台打印完整带参数SQL语句
    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
    call-setters-on-nulls: true
  # 这里根据自己项目的包修改,扫描到自己的*xml文件
  mapper-locations: classpath:xx/xx/xx/**/mapper/*.xml

通过这两步的配置,成功解决了我的问题

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐