我使用以下Maven命令创建了Web App测试项目:
mvn archetype:generate -DgroupId=com.vanilla.cache -DartifactId=TestProject -DarchetypeArtifactId=maven-archetype-webapp -DinteractiveMode=false
之后,我将该项目转换为Eclipse
mvn eclipse:eclipse -Dwtpversion=2.0
之后,我在Eclipse中以及当我使用Tomcat 7.0运行它时创建了一个名为com.vanilla.test.TestServlet的新Servet。我收到以下错误。
SEVERE: Allocate exception for servlet Test java.lang.ClassNotFoundException: com.vanilla.test.TestServlet at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1678) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1523) at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:525) at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:507) at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:126) at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1099) at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:836) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:135) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:405) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:964) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:515) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:304) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) at java.lang.Thread.run(Thread.java:679)
请帮忙。我想念什么?
我解决了问题。
项目->属性-> Java构建路径->源。
我添加了/ src并重新启动了tomcat。