Ale*_*uch 17 java eclipse deployment jsf maven
摘要
在Eclipse中,当我"Maven->更新项目配置""Maven Dependencies"从我的项目的"部署程序集"中删除时.
细节
我从一个预配置的Eclipse项目开始:File-> New-> Dynamic Web Project-> JavaServer Face v2.0 Project.为了删除"魔术",我将其转换为Maven项目:Configure-> Convert to Maven project.
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>
<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>
Run Code Online (Sandbox Code Playgroud)
然后,为了确保在部署之前将Maven依赖项复制到"WEB-INF/lib /",我将它们添加到项目的"部署程序集":项目属性 - >部署程序集.有关更多详细信息,请参阅此问题:Eclipse + Maven + JavaServer Faces - > ClassNotFoundException:StartupServletContextListener.
我知道有两个相关的问题.
问题
(1)当我"Project-> Maven->更新项目配置"时,"Maven依赖关系"将从我的"部署程序集"中删除.有没有办法阻止这种情况发生,可能是通过一些Maven插件?
(2)当我从Eclipse中构建.war时,一切都很好,.war在Tomcat中运行正常.但是当我从Maven的命令行构建它时mvn clean compile war:war
,"WebContent /"中的.html文件没有添加到.war中.同样,我需要哪些Maven设置/插件来解决这个问题?
仅供参考,这是一个非常基本的应用程序......只是一个登录页面和一个欢迎页面.
如果我应该提供任何其他详细信息(web.xml,faces-config-xml,login.xhtml),请告诉我,我会添加它们.
谢谢
- 编辑 -
Eclipse版本:3.6.2
Eclipse m2e版本:1.0.1
Apache Maven版本:2.2.1
(1)解决方案
已更新至Eclipse Java EE 3.7.2(Indigo).现在还使用m2e-wtp Maven Integration for Eclipse WTP插件
(2)解决方案
从原型创建新的Maven项目,然后是Eclipse-> Import-> Existing Maven Project.使用新的Eclipse版本和m2e-wtp,Eclipse中的Java EE透视图可以很好地与标准的Maven目录结构配合使用
pom.xml现在也更简单了:
<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>
Run Code Online (Sandbox Code Playgroud)
我建议迁移到 Eclipse 3.7.x (Indigo),它对m2e有更好的支持,并且还允许您使用Maven Integration for WTP(单独安装),这应该会让事情变得更容易。我想您的大部分问题应该通过更新到 Indigo 来解决。
安装链接: http: //marketplace.eclipse.org/node/96737
另请参阅此处:Eclipse Indigo/3.7 中的 Maven/Tomcat 项目
编辑
将 Web 资源放在WebContent下,然后将其添加为 WAR 插件中的目录可能是一个解决方案。干净的方法是将它们放在src/main/resources
或下src/main/webapp
,并且它们应该自动包含在 WAR 文件中。WebContent
不是 Maven 的标准目录之一。
归档时间: |
|
查看次数: |
29022 次 |
最近记录: |