在Eclipse

时间:2016-11-15 13:40:53

标签: java eclipse tomcat

我是Java的新手,我从Gitlab克隆了一个项目并将其导入Eclipse。

我还添加了tomcat服务器,还为项目和tomcat服务器设置了属性。

我目前在Eclipse中添加了2个项目,其中一个工作正常,但另一个项目失败。我已经为另一个项目的服务器更改了端口。

看起来有些文件丢失了吗?

我在这里经历了很多答案,但没有人帮忙。

但是在运行第二个项目时,我遇到了以下错误:

INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
Nov 15, 2016 7:41:27 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 411 ms
Nov 15, 2016 7:41:27 AM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Nov 15, 2016 7:41:27 AM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.72
Nov 15, 2016 7:41:27 AM org.apache.catalina.core.ContainerBase startInternal
SEVERE: A child container failed during start
java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/ProductEngine]]
    at java.util.concurrent.FutureTask.report(FutureTask.java:122)
    at java.util.concurrent.FutureTask.get(FutureTask.java:192)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1119)
    at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:819)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1571)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1561)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/ProductEngine]]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:162)
    ... 6 more
Caused by: java.lang.NoClassDefFoundError: Lorg/apache/commons/logging/Log;
    at java.lang.Class.getDeclaredFields0(Native Method)
    at java.lang.Class.privateGetDeclaredFields(Class.java:2583)
    at java.lang.Class.getDeclaredFields(Class.java:1916)
    at org.apache.catalina.util.Introspection.getDeclaredFields(Introspection.java:106)
    at org.apache.catalina.startup.WebAnnotationSet.loadFieldsAnnotation(WebAnnotationSet.java:270)
    at org.apache.catalina.startup.WebAnnotationSet.loadApplicationListenerAnnotations(WebAnnotationSet.java:89)
    at org.apache.catalina.startup.WebAnnotationSet.loadApplicationAnnotations(WebAnnotationSet.java:63)
    at org.apache.catalina.startup.ContextConfig.applicationAnnotationsConfig(ContextConfig.java:417)
    at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:891)
    at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:388)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
    at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5522)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
    ... 6 more
Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.Log
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1892)
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1735)
    ... 20 more

更新:我的pom.xml如下所示,它没有提供状态

enter image description here

2 个答案:

答案 0 :(得分:1)

Java Common Logging lib似乎在您的项目中提供范围。

您可以修改pom.xml以删除"提供的"范围,或者将公共日志记录JAR放在tomcat lib目录中。我建议你使用第一种可能性

编辑:在谈到Neel之后,问题是maven项目没有完全正确设置。实际上,Eclipse在Tomcat上部署项目时没有部署maven依赖项 所以解决这个问题的方法是:
right click on project > deployment assembly > Add > Java Build path entry > Maven dependencies

答案 1 :(得分:0)

右键单击您的项目,Maven - >更新项目。然后你必须选择你的项目并进行更新。

如果你没有看到" Maven"右键单击项目时,您必须执行以下操作:右键单击项目,配置 - >转换为Maven项目。

希望它有所帮助。