Property ‘mapperLocations‘ was not specified.

项目启动的时候,控制台输出:
Property 'mapperLocations' was not specified.
且调用数据库保存实体的时候报错:
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.sh.save
Property ‘mapperLocations‘ was not specified._第1张图片经过查询,是没有扫描到xml文件。解决方法很多,本人采用如下方法:
在pom.xml 中,标签之间,添加:

<resources>
      <resource>
          
          <directory>src/main/javadirectory>
          <includes>
              <include>**/*.xmlinclude>
          includes>
      resource>
      
      <resource>
          <directory>src/main/resourcesdirectory>
      resource>
 resources>

这样在pom中声明,打包的时候会把配置文件一起打包。在yml配置mybatis-plus的配置项中,mapper-locations的路径需要以classpath*: 开头。Maven 多模块项目的扫描路径需以 classpath*: 开头 (即加载多个 jar 包下的 XML 文件)

你可能感兴趣的:(Java随笔,java)