报错:Parsed mapper file: ‘file mapper.xml

报错 :

Logging initialized using 'class org.apache.ibatis.logging.stdout.StdOutImpl' adapter.
Registered plugin: 'com.github.yulichang.interceptor.MPJInterceptor@3b2c8bda'
Parsed mapper file: 'file /Mapper.xml'

application无法启动

我这边产生原因是项目中添加了 mybayis-plus-join插件 导致这个问题

然后本人一顿骚操作:升级到JDK17 升级 到maven3.9.6 痛苦无比报错依旧,有说sql写错的。我就没几条sql 哈哈

然后 mvn clean install 构建成功 但是启动依旧报错 崩溃中。。。。。。。

取消掉所有mapper文件的extends MPJBaseMapper<> 报错依旧

取消掉断点 报错还是依旧

打钩的先全部取消掉

最后的问题是项目没有识别到mapper下的xml文件 。 路径配置问题。。需要重新导入maven

此时网上关于这个报错基本已经试完 可是我的报错依旧。。。。

相关概念:

maven项目结构:

src/main/java 默认加载java文件 一般只放java文件

src/main/resources 默认放各种配置文件,如html yaml文件 css文件,xml文件等

因此 src/main目录下的java文件编译后都在 target/classes目录下。

所有 classpath的意思是 项目根路径 也就是 target/classes

因此,将所有的xml文件放置到resources目录下 即可识别出xml文件

问题解决

但是我偏偏就是把xml想放在mapper下。 /src/main/mapper

需要再pom.xml文件中 配置一下

html 复制代码
<build>
    <resources>
        <resource>
            <directory>src/main/java/</directory>
            <includes>
                <include>**/*.xml</include>
            </includes>
        </resource>
</resources>
</build>

applicaton,yml中的配置

html 复制代码
mybatis-plus:
  mapper-locations: classpath:**/mapper/*.xml
  configuration:
    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
    call-setters-on-nulls: true

但是我的问题是这样配置之后还是不识别 还是报错怎么办?

只能让idea重新指定一个配置文件 resource文件

idea-》 setting->modules-> Resources

搞定 真是太蛋疼了。。。。

相关推荐
许彰午2 天前
在PowerBuilder里手写XML序列化——没有现成库的年代怎么拼报文
xml·linux·服务器
坚果的博客3 天前
鸿蒙PC三方库适配OAT.xml 与 SHA512SUM 解读:开源合规与源码校验
xml·开源·harmonyos
奇树谦3 天前
YAML、XML、JSON、TOML、INI、CSV 全面对比:配置文件和数据交换到底该怎么选?
xml·json
南山丶无梅落4 天前
XXE漏洞
xml·漏洞·xxe·网安
小书房4 天前
Android UI为什么由XML转向Compose
xml·ui·compose·声明式ui
学编程的小程4 天前
配置范式演进:XML、JavaConfig 与 Spring Boot
xml·spring boot·后端
le1616165 天前
Android Compose基础布局——从传统XML的视角切入了解
xml·compose
XiYang-DING6 天前
【MyBatis】XML方式实现CRUD
xml·mybatis
祭曦念8 天前
ArkUI声明式UI入门:从XML到声明式的思维转变
xml·ui·鸿蒙
Meteors.10 天前
安卓源码阅读——01.grade设置binding为true时,xml如何进行映射
android·xml