BUG 日志

可见是bean创建异常,依赖注入失败

org.springframework.beans.factory.BeanCreationException: Error creating 
bean with name 'buyServiceImpl': Injection of resource dependencies 
failed; nested exception is org.springframework.beans.factory.
BeanCreationException: Error creating bean with name 'orderServiceImpl'
defined in file [D:\workspace\java\ideaworkspace\springcloud\seata-buy\target
\classes\com\xt\springcloud\service\impl\OrderServiceImpl.class]: 
Post-processing of merged bean definition failed; nested exception is java.lang.
IllegalStateException: Failed to introspect Class 
[com.xt.springcloud.service.impl.OrderServiceImpl] from ClassLoader 
[sun.misc.Launcher$AppClassLoader@18b4aac2]

并且还打印了类的全路径信息

D:\workspace\java\ideaworkspace\springcloud\seata-buy\target\classes
\com\xt\springcloud\service\impl\OrderServiceImpl.class

因为我更改了这个项目的结构,这些文件都已经被我删除了
而日志里面的这个文件是先前项目编译的时候所生成的

在这里插入图片描述

target 目录介绍

项目编译后自动生成的项目文件,使用maven打包后的文件也会在此处。

解决方案

idea不会自动将新保存的文件或目录及其他资源更新到target目录中,必须在pom.xml中设置

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

然后maven clean 一下,他会删除掉这个项目的target目录
在这里插入图片描述
重启一下项目,就会重新编译代码,生成新的target目录文件,就可以正常运行了

在这里插入图片描述

References:

  • https://zhuanlan.zhihu.com/p/198191092
  • https://www.cnblogs.com/caiba/p/8651791.html?ivk_sa=1024320u

(写博客主要是对自己学习的归纳整理,资料大部分来源于书籍、网络资料、官方文档和自己的实践,整理的不足和错误之处,请大家评论区批评指正。同时感谢广大博主和广大作者辛苦整理出来的资源和分享的知识。)

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐