【问题标题】:on update maven project it removes the attribute name="org.eclipse.jst.component.dependency" in eclipse in .classpath file在更新 maven 项目时,它会在 .classpath 文件中删除 eclipse 中的属性 name="org.eclipse.jst.component.dependency"
【发布时间】:2015-11-27 13:22:35
【问题描述】:

项目描述:

  • 动态网络项目。
  • Maven 依赖项我使用 Eclipse 默认编译来编译项目。我没有编译项目 行家。
  • java 6(在 pom.xml 中提到源和目标为 java 6,但当前在 eclipse 中安装的版本是 java 7)。
  • 它是一个网络应用程序。我在项目中使用了jsf、hibernate、spring、spring-security。

以下几行来自我在 Eclipse 中用于该项目的“.classpath”文件。

<classpathentry exported="true" kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
    <attributes>
        <attribute name="maven.pomderived" value="true"/>
        <attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
    </attributes>
</classpathentry>

如果我更新 Maven,右键单击项目,Maven -> 更新项目。我发现类路径中的变化。

 <attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>

上面的行丢失了。没有这个,我的项目没有在 Eclipse 的 tomcat 中运行。 我正在尝试通过使用键盘快捷键“shift-alt-x R”选择“在服务器上运行”选项来运行此项目。

之前同样的项目正在运行。从这个项目的新安装的 SVN 更新项目后,我面临这个问题。帮助我从哪里开始找到问题。如果需要,请询问更多信息,以便您可以帮助我解决此问题。

这里是堆栈跟踪的一部分,

SEVERE: A child container failed during start
java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/MyProject]]
at java.util.concurrent.FutureTask.report(FutureTask.java:122)
at java.util.concurrent.FutureTask.get(FutureTask.java:188)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:917)
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:871)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1409)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1399)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)

【问题讨论】:

  • 您是否将项目导入为现有的 maven 项目?
  • 是的,它是一个 Maven 项目。正因为如此,我才能在右键单击项目时选择“maven -> update project”选项。我将在此处添加到达此处的实际问题和解决方案作为答案。

标签: java eclipse maven web-applications classpath


【解决方案1】:

其实这是一个java版本相关的问题。由于该项目依赖于在带有 java 6 的服务器中运行的 java 项目,因此我们已将该项目从 java 7 降级到 java 6。

我已经更改了运行时、构建路径和指向 java 6 的 pom.xml。但是,忘记更改 web.xml 标头端点。

因此,在更新项目时,eclipse 突然发现这是一个 web 项目。

即,

来自 (java 7)

<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
id="WebApp_ID" 
version="3.1">

到 (java 6)

<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID" 
version="3.0">

在此更改之后,在“maven-> update project”上,我得到了正确的项目设置。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-01-02
    • 2011-06-18
    • 2011-05-20
    • 1970-01-01
    • 2013-11-08
    • 1970-01-01
    • 2017-03-03
    • 1970-01-01
    相关资源
    最近更新 更多