Ruoyi若依在IDEA部署Tomcat报错class path resource [……class] cannot be opened because it does not exist

完整报错内容:

24-Nov-2023 14:26:05.157 [RMI TCP Connection(2)-127.0.0.1] ERROR o.s.b.SpringApplication - [reportFailure,858] - Application run failed
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class [com.ruoyi.RuoYiApplication]; nested exception is java.io.FileNotFoundException: class path resource [com/ruoyi/common/core/controller/BaseController.class] cannot be opened because it does not exist
		at……
	Caused by: java.io.FileNotFoundException: class path resource [com/ruoyi/common/core/controller/BaseController.class] cannot be opened because it does not exist
		at……
24-Nov-2023 14:26:05.165 严重 [RMI TCP Connection(2)-127.0.0.1] org.apache.catalina.core.ContainerBase.addChildInternal ContainerBase.addChild: start: 
	org.apache.catalina.LifecycleException: 无法启动组件[StandardEngine[Catalina].StandardHost[localhost].StandardContext[/ruoyi_admin_war_exploded]]
		at……
	Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class [com.ruoyi.RuoYiApplication]; nested exception is java.io.FileNotFoundException: class path resource [com/ruoyi/common/core/controller/BaseController.class] cannot be opened because it does not exist
	    at……
	Caused by: java.io.FileNotFoundException: class path resource [com/ruoyi/common/core/controller/BaseController.class] cannot be opened because it does not exist
		at……
24-Nov-2023 14:26:05.169 严重 [RMI TCP Connection(2)-127.0.0.1] org.apache.tomcat.util.modeler.BaseModelMBean.invoke Exception invoking method manageApp
	java.lang.IllegalStateException: 启动子级时出错
		at……
	Caused by: org.apache.catalina.LifecycleException: 无法启动组件[StandardEngine[Catalina].StandardHost[localhost].StandardContext[/ruoyi_admin_war_exploded]]
		at……
	Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class [com.ruoyi.RuoYiApplication]; nested exception is java.io.FileNotFoundException: class path resource [com/ruoyi/common/core/controller/BaseController.class] cannot be opened because it does not exist
		at……
	Caused by: java.io.FileNotFoundException: class path resource [com/ruoyi/common/core/controller/BaseController.class] cannot be opened because it does not exist
		at……
24-Nov-2023 14:26:05.186 严重 [RMI TCP Connection(2)-127.0.0.1] org.apache.tomcat.util.modeler.BaseModelMBean.invoke Exception invoking method createStandardContext
	javax.management.RuntimeOperationsException: Exception invoking method manageApp
		at……
	Caused by: java.lang.IllegalStateException: 启动子级时出错
		at……
	Caused by: org.apache.catalina.LifecycleException: 无法启动组件[StandardEngine[Catalina].StandardHost[localhost].StandardContext[/ruoyi_admin_war_exploded]]
		at……
	Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class [com.ruoyi.RuoYiApplication]; nested exception is java.io.FileNotFoundException: class path resource [com/ruoyi/common/core/controller/BaseController.class] cannot be opened because it does not exist
		at……
	Caused by: java.io.FileNotFoundException: class path resource [com/ruoyi/common/core/controller/BaseController.class] cannot be opened because it does not exist
		at……
[2023-11-24 02:26:05,250] Artifact ruoyi-admin:war exploded: Error during artifact deployment. See server log for details.

在Tomcat和maven都配置好的情况下,将项目打包到Tomcat发布出现以上报错。
检查前期操作:

1. 检查环境变量

(1)maven

我的电脑(右键)->属性->高级系统设置->环境变量:

  • 检查系统变量MAVEN_HOME的变量值路径是否正确
    在这里插入图片描述
  • 检查系统变量PATH中关于MAVEN的路径是否正确
    在这里插入图片描述

(2)Tomcat

  • 检查系统变量CATALINA_HOME的变量值路径是否正确
    在这里插入图片描述
  • 检查系统变量PATH中关于CATALINA的路径是否正确
    在这里插入图片描述

2.检查IDEA

File->Settings->Maven:

  • 检查Maven home、setting.xml文件和本地仓库的路径是否正确
    在这里插入图片描述

File->Project Structure->Artifacts:

  • 检查ruoyi-admin:war exploded是否存在
    在这里插入图片描述

  • 如果不存在,左上角“+”->Web Application:Exploded->From Modules添加ruoyi-admin,Apply->OK
    在这里插入图片描述

Run->Edit Configurations…

  • 检查左侧是否配置Tomcat Server
    在这里插入图片描述

  • 没有就左上角“+”,找到Tomcat Server,选择Local
    在这里插入图片描述

  • 检查Deployment中是否配置刚刚Artifacts中添加的ruoyi-admin:war exploded
    在这里插入图片描述

  • 没有就添加,然后Apply->OK

3. 出现bug

如果以上配置均无问题,并且maven仓库已经下载好依赖的情况下出现了该报错,可以尝试以下方法:

ruoyi-admin中的pom.xml文件

  • 大概11行的位置,jar改成war

在这里插入图片描述

  • 然后就是比较随机的操作了,以下操作任选(最好一个个试),有的重启IDEA就可以,有的删掉.idea才可以

1.maven clean,然后package
2.重启IDEA
3.重启电脑
4.【迫不得已】删掉根目录的.idea文件,重启IDEA(需要重新在IDEA里配置maven和Tomcat)

OK.

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值