java 错误 classes路径配置错误

1. 错误显示页

2. 解决步骤

2.1. 查看 root cause 信息

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'urlMapping' defined in ServletContext resource [/WEB-INF/spring-servlet.xml]: Initialization of bean failed; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [com.myweb.IndexAction] for bean with name 'IndexAction' defined in ServletContext resource [/WEB-INF/spring-servlet.xml]; nested exception is java.lang.ClassNotFoundException: com.myweb.IndexAction
Related cause: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [com.myweb.IndexAction] for bean with name 'IndexAction' defined in ServletContext resource [/WEB-INF/spring-servlet.xml]; nested exception is java.lang.ClassNotFoundException: com.myweb.IndexAction

2.2. 分析信息点

  很明显是找不到 IndexAction,也就是IndexAction.java生成的IndexAction.class。

2.3. 问题路径分析

2.3.1. 路径不对

  指的是Classes路径不对,应该是在 myweb/webapp/WEB-INF/classes/。这是本次错误的原因,这个路径配置错误。

2.3.2. 文件没有生成

  是否在2.3.1 下有对应的文件生成

2.3.3. 其它原因

  除了上述两个原因,还可能有别的衍生问题。执行Index.do时,要根据配置找到对应的IndexAction.class。但是现在没有找到,也可以反过来解决,就是配置没有配对。

原文地址:https://www.cnblogs.com/SimonGao/p/4960928.html