Eclipse + Maven +动态Web项目 - > Maven覆盖部署程序集 [英] Eclipse + Maven + Dynamic Web Project -> Maven overwrites Deployment Assembly

查看:231
本文介绍了Eclipse + Maven +动态Web项目 - > Maven覆盖部署程序集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

摘要



在Eclipse中,当我Maven->更新项目配置Maven依赖关系从部署程序集我的项目。



详细信息



我从预先配置Eclipse项目:File-> New-> Dynamic Web Project-> JavaServer Face v2.0 Project。为了删除魔法,我将其转换为Maven项目:配置 - >转换为Maven项目。



pom.xml包含以下内容:

 < build> 
< finalName> jsf-facelets-tutorial< / finalName>
< plugins>
< plugin>
< groupId> org.apache.maven.plugins< / groupId>
< artifactId> maven-war-plugin< / artifactId>
< configuration>
< webXml> WebContent / WEB-INF / web.xml< / webXml>
< / configuration>
< / plugin>
< plugin>
< groupId> org.apache.maven.plugins< / groupId>
< artifactId> maven-compiler-plugin< / artifactId>
< configuration>
< source> 1.6< / source>
< target> 1.6< / target>
< / configuration>
< / plugin>
< / plugins>
< / build>
<依赖关系>
<依赖关系>
< groupId> javax.el< / groupId>
< artifactId> el-api< / artifactId>
< version> 1.0< / version>
< scope>已提供< / scope>
< / dependency>
<依赖关系>
< groupId> junit< / groupId>
< artifactId> junit< / artifactId>
< version> 4.0< / version>
< scope> test< / scope>
< / dependency>
<依赖关系>
< groupId> org.apache.myfaces.core< / groupId>
< artifactId> myfaces-api< / artifactId>
< version> 2.0.5< / version>
< scope> compile< / scope>
< / dependency>
<依赖关系>
< groupId> org.apache.myfaces.core< / groupId>
< artifactId> myfaces-impl< / artifactId>
< version> 2.0.5< / version>
< scope>运行时< / scope>
< / dependency>
< / dependencies>

然后,确保在部署前将Maven依赖项复制到WEB-INF / lib / ,
我将它们添加到项目的部署程序集中:项目属性 - >部署程序集。有关详细信息,请参阅此问题: Eclipse + Maven + JavaServer Faces - > ClassNotFoundException:StartupServletContextListener



我知道有两个相关问题。



/ strong>



(1)当我Project-> Maven->更新项目配置时,Maven Dependencies将从我的部署大会。有没有办法阻止这种情况发生,可能通过一些Maven插件?



(2)当我从Eclipse中构建.war一切都很好,.war在Tomcat中运行良好。但是当我使用Maven命令行构建它时,,WebContent /中的.html文件不会添加到.war中。再次,哪些Maven设置/插件需要补救?



FYI,这是一个非常基本的应用程序...只是登录页面和欢迎页面。 p>

如果有任何其他细节我应该提供(web.xml,faces-config-xml,login.xhtml),让我知道,我会添加它们。 p>

谢谢



- 编辑 -



Eclipse版本:3.6.2



Eclipse m2e版本:1.0.1



Apache Maven版本:2.2.1



(1)解决方案



Java EE 3.7.2(Indigo)。现在还使用 m2e-wtp Maven Integration for Eclipse WTP插件



(2)解决方案



原型,然后是Eclipse-> Import-> Existing Maven Project。使用新的Eclipse版本和m2e-wtp,Eclipse中的Java EE透视图可以很好地与标准的Maven目录结构



pom.xml现在也更简单: p>

 < build> 
< finalName> jsf-facelets-tutorial< / finalName>
< plugins>
< plugin>
< groupId> org.apache.maven.plugins< / groupId>
< artifactId> maven-war-plugin< / artifactId>
< / plugin>
< plugin>
< groupId> org.apache.maven.plugins< / groupId>
< artifactId> maven-compiler-plugin< / artifactId>
< configuration>
< source> 1.6< / source>
< target> 1.6< / target>
< / configuration>
< / plugin>
< / plugins>
< / build>
<依赖关系>
<依赖关系>
< groupId> javax.el< / groupId>
& artifactId> el-api< / artifactId>
< version> 1.0< / version>
< scope>已提供< / scope>
< / dependency>
<依赖关系>
< groupId> junit< / groupId>
< artifactId> junit< / artifactId>
< version> 4.0< / version>
< scope> test< / scope>
< / dependency>
<依赖关系>
< groupId> org.apache.myfaces.core< / groupId>
< artifactId> myfaces-api< / artifactId>
< version> 2.0.5< / version>
< scope> compile< / scope>
< / dependency>
<依赖关系>
< groupId> org.apache.myfaces.core< / groupId>
< artifactId> myfaces-impl< / artifactId>
< version> 2.0.5< / version>
< scope>运行时< / scope>
< / dependency>
< / dependencies>


解决方案

我建议移至Eclipse 3.7.x Indigo),它更好地支持了 m2e ,并且还允许您使用用于WTP的Maven集成(单独安装),这应该使事情变得更加容易。我想大部分的问题都应该通过更新到Indigo来解决。



安装链接: http://marketplace.eclipse.org/node/96737



另请参见: Maven/Tomcat项目在Eclipse Indigo / 3.7



编辑
将您的Web资源放在 WebContent 之前,然后将其添加为WAR插件中的目录可能是一个解决方案。干净的方式是让他们在 src / main / resources src / main / webapp 之下,他们应该自动包含在WAR文件中。 WebContent 不是Maven的标准目录之一。


Summary

In Eclipse, when I "Maven->Update Project Configuration" "Maven Dependencies" gets removed from the "Deployment Assembly" of my project.

Details

I started with a pre-configured Eclipse project: File->New->Dynamic Web Project->JavaServer Face v2.0 Project. To remove the "magic" I then converted it to a Maven project: Configure->Convert to Maven project.

pom.xml contains the following:

<build>
    <finalName>jsf-facelets-tutorial</finalName>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <configuration>
                <webXml>WebContent/WEB-INF/web.xml</webXml>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>
        </plugin>
    </plugins>
</build>
<dependencies>
    <dependency>
        <groupId>javax.el</groupId>
        <artifactId>el-api</artifactId>
        <version>1.0</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.0</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.myfaces.core</groupId>
        <artifactId>myfaces-api</artifactId>
        <version>2.0.5</version>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.myfaces.core</groupId>
        <artifactId>myfaces-impl</artifactId>
        <version>2.0.5</version>
        <scope>runtime</scope>
    </dependency>
</dependencies>

Then, to make sure the Maven dependencies are copied to "WEB-INF/lib/" before deploying, I added them to the project's "Deployment Assembly": Project Properties->Deployment Assembly. For more details, see this question: Eclipse + Maven + JavaServer Faces -> ClassNotFoundException: StartupServletContextListener.

I know have two related problems.

Problems

(1) When I "Project->Maven->Update Project Configuration", "Maven Dependencies" gets removed from my "Deployment Assembly". Is there a way to stop this from happening, possibly via some Maven plugin?

(2) When I build the .war from within Eclipse everything is fine, the .war runs fine in Tomcat. But when I build it from command line with Maven, mvn clean compile war:war, the .html files from "WebContent/" is not added to the .war. Again, Which Maven settings/plugins do I need to remedy this?

FYI, it's a very basic application... just a login page and a welcome page.

If there are any additional details I should provide (web.xml, faces-config-xml, login.xhtml), let me know and I'll add them.

Thanks

--EDIT--

Eclipse version: 3.6.2

Eclipse m2e version: 1.0.1

Apache Maven version: 2.2.1

(1) Solution

Updated to Eclipse Java EE 3.7.2 (Indigo). Now also using m2e-wtp Maven Integration for Eclipse WTP plugin

(2) Solution

Created new Maven project from archetype, then Eclipse->Import->Existing Maven Project. With new Eclipse version and the m2e-wtp, the Java EE perspective in Eclipse works well with the standard Maven directory structure

The pom.xml is now simpler too:

<build>
    <finalName>jsf-facelets-tutorial</finalName>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>
        </plugin>
    </plugins>
</build>
<dependencies>
    <dependency>
        <groupId>javax.el</groupId>
        <artifactId>el-api</artifactId>
        <version>1.0</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.0</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.myfaces.core</groupId>
        <artifactId>myfaces-api</artifactId>
        <version>2.0.5</version>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.myfaces.core</groupId>
        <artifactId>myfaces-impl</artifactId>
        <version>2.0.5</version>
        <scope>runtime</scope>
    </dependency>
</dependencies>

解决方案

I would recommend to move to Eclipse 3.7.x (Indigo), which has better support for m2e, and also allows you to use the Maven Integration for WTP (separate install), which should make things a lot easier. I guess most of your problems should be solved by updating to Indigo.

Install Link: http://marketplace.eclipse.org/node/96737

Also see here: Maven/Tomcat Projects In Eclipse Indigo/3.7

Edit Putting your web resources under WebContent and then adding that as a directory in the WAR plugin may be a solution. The clean way would be to have them under src/main/resources or src/main/webapp and they should be included automatically in the WAR file. WebContent is not one of Maven's standard directories.

这篇关于Eclipse + Maven +动态Web项目 - &gt; Maven覆盖部署程序集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆