关于IDEA中mapper改名,打包后仍为原名的问题的解决方案

3 篇文章 0 订阅

报错:

12:50:52.361 [http-nio-8080-exec-6] ERROR org.springframework.web.servlet.DispatcherServlet - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sign' defined in file [D:\Bin\Net\apache-tomcat-9.0.41\webapps\Aplp\WEB-INF\classes\xyz\zixiu\aplp\Controller\Sign.class]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [xyz.zixiu.aplp.Controller.Sign]: Constructor threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactoryUser' defined in class path resource [ApplicationContext/ac-SqlSessionsFactoryUser.xml]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: 'class path resource [Mapper/User/StudentMapper.xml]'; nested exception is java.io.FileNotFoundException: class path resource [Mapper/User/StudentMapper.xml] cannot be opened because it does not exist

找不到 Mapper/User/StudentMapper.xml

但我的项目目录里面是有的

而我到打包后的目录apache-tomcat-9.0.41\webapps\Aplp\WEB-INF\classes里面去找的时候发现,他是有的,但名字是小写,是这个目录以前的文件名,这可能是因为IDEA的重构的执行问题

PS C:\Users\zixiu> cd D:\Bin\Net\apache-tomcat-9.0.41\webapps\Aplp\WEB-INF\classes
PS D:\Bin\Net\apache-tomcat-9.0.41\webapps\Aplp\WEB-INF\classes> ls


    目录: D:\Bin\Net\apache-tomcat-9.0.41\webapps\Aplp\WEB-INF\classes


Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d-----         2021/4/23     12:50                ApplicationContext
d-----         2021/4/23     12:50                DB
d-----         2021/4/23     12:50                mapper
d-----         2021/4/23     12:50                Properties
d-----         2021/4/23     12:50                User
d-----         2021/4/23     12:50                xyz
-a----         2021/4/23     12:32            733 applicationContext-DB.xml
-a----         2021/4/23     12:32            735 applicationContext-User.xml
-a----         2021/4/22     13:16           3738 log4j.properties
-a----         2021/4/23     12:32           1330 spring-mvc.xml

解决方案就是将 .idea/workspace.xml里面出现所有的原文件名都改成现文件名

(这些配置也可能在idea/artifacts下面的两个xml文件里)

例如我把

<change beforePath="$PROJECT_DIR$/config/mapper/DB/DBMapper.xml" beforeDir="false" afterPath="$PROJECT_DIR$/config/Mapper/DB/DBMapper.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/config/mapper/User/AdminMapper.xml" beforeDir="false" afterPath="$PROJECT_DIR$/config/Mapper/User/AdminMapper.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/config/mapper/User/StudentMapper.xml" beforeDir="false" afterPath="$PROJECT_DIR$/config/Mapper/User/StudentMapper.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/config/mapper/User/TeacherMapper.xml" beforeDir="false" afterPath="$PROJECT_DIR$/config/Mapper/User/TeacherMapper.xml" afterDir="false" />

改成了

<change beforePath="$PROJECT_DIR$/config/Mapper/DB/DBMapper.xml" beforeDir="false" afterPath="$PROJECT_DIR$/config/Mapper/DB/DBMapper.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/config/Mapper/User/AdminMapper.xml" beforeDir="false" afterPath="$PROJECT_DIR$/config/Mapper/User/AdminMapper.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/config/Mapper/User/StudentMapper.xml" beforeDir="false" afterPath="$PROJECT_DIR$/config/Mapper/User/StudentMapper.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/config/Mapper/User/TeacherMapper.xml" beforeDir="false" afterPath="$PROJECT_DIR$/config/Mapper/User/TeacherMapper.xml" afterDir="false" />

 

 

用替换毕竟方便,不会漏,但一定要把关键词尽量填完整,不然容易误伤别的句子

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值