6

I working with a maven project in eclipse and am having trouble with getting the deployment to work without some manual editing of xml files.

When I build the project through maven I get a org.eclipse.wst.common.component xml file in my .settings folder. The file looks like the following:

<?xml version="1.0" encoding="UTF-8"?>
<project-modules id="moduleCoreId" project-version="1.5.0">
    <wb-module deploy-name="ins-web">           
        <wb-resource deploy-path="/" source-path="/WebContent"/>
        <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/java"/>
        <property name="context-root" value="ins-web"/>
        <property name="java-output-path"/>
    </wb-module>
</project-modules>

The following line is causing the problem:

<wb-resource deploy-path="/" source-path="/WebContent"/>

Its looking to deploy everything below the WebContent folder when really it should be looking in src/webapp. The line should therefore look like this:

<wb-resource deploy-path="/" source-path="/src/webapp"/>

If I change it manually then it all works fine but I'd like to know if there is a way to avoid manually changing the file to make the build process easier for other people on my team.

4

3 回答 3

4

你是如何生成你的eclipse文件的。您使用的是m2eclipse Eclipse 插件还是使用maven-eclipse-plugin?m2eclipse 是 Eclipse 的一个插件,在 Eclipse 中运行。maven-eclipse-plugin 是一个从 cmd 行运行的 Maven 插件,用于根据您的 pom.xml 生成 Eclipse 项目文件。

我一直使用 maven-eclipse-plugin 取得了更好的成功。m2eclipse 的作者不建议您尝试同时使用这两个插件。

如果您使用的是 maven-eclipse-plugin,您应该检查几件事。

  1. 使用最新的 maven-eclipse-plugin 2.7 版。
  2. 确保您的项目是“战争”包装
  3. 配置 maven-war-plugin 并根据需要设置战争源目录。将以下代码段添加到您的 pom.xml。这就是 maven-eclipse-plugin 确定您的 webapp 所在位置的方式。
  <插件>  
    <artifactId>maven-war-plugin</artifactId>  
    <version>2.1-beta-1</version>  
    <配置>  
      <warSourceDirectory>src/webapp</warSourceDirectory>  
    </配置>  
  </插件>

进行这些更改并mvn eclipse:clean eclipse:eclipse再次运行后,您应该会在组件文件中看到预期值。

于 2010-01-12T17:23:24.633 回答
2

在 maven-eclipse-plugin 配置中添加...

<additionalConfig>
  <file>
    <name>.settings/org.eclipse.wst.common.component</name>
    <content>
      <![CDATA[Your file content here
      ]]>
    </content>
  </file>
</additionalConfig>
于 2011-01-05T16:27:14.390 回答
0

好吧,要重新生成 JAR 文件(仅),在项目上,右键单击 > 属性 > 项目构面: - 选中 Java 选项并选择 Java 版本。它将在.settings文件夹中生成文件org.eclipse.wst.common.project.facet.core - 检查实用程序模块。它将在.settings文件夹中生成文件org.eclipse.wst.common.component - 单击应用按钮和/或确定按钮

这只是为您的 IDE 环境生成文件的一种方式。据我们了解,m2e-wtp 无法正确生成文件的一个原因是“坏”的 POM。似乎项目方面是从 pom.xml 文件及其与其他项目/模块之间的关系推导出来的(例如:与 Web 模块/Java EE 项目类型的依赖关系)。

于 2013-06-19T13:04:42.907 回答