eclipse 带有 Java Server Faces 1.2 的 Maven Java EE 配置标记
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15115009/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Maven Java EE Configuration Marker with Java Server Faces 1.2
提问by Tarek
I'm having a weird configuration problem with Maven in Eclipse. Although I can build the project and deploy it to tomcat without any errors, The Marker tab keeps showing the following message:
我在 Eclipse 中遇到了一个奇怪的 Maven 配置问题。虽然我可以构建项目并将其部署到 tomcat 没有任何错误,但标记选项卡一直显示以下消息:
[-] Maven Java EE Configuration Problem
(x) JavaServer Faces 1.2 can not be installed : One or more constraints have not been satisfied.
(x) JavaServer Faces 1.2 requires Dynamic Web Module 2.5 or newer.
I am in fact using Dynamic Web Module 2.4, which would be the source of the message. I would need to change it to at least 2.5 to work with JSF. Problem is, I'm not even using JSF.
我实际上使用的是动态 Web 模块 2.4,这将是消息的来源。我需要将其更改为至少 2.5 才能使用 JSF。问题是,我什至没有使用 JSF。
So, probably one of the project's dependencies needs it. I ran the following command to find out the dependency tree for my project:
因此,可能项目的依赖项之一需要它。我运行以下命令来找出我的项目的依赖树:
mvn dependency:tree -DoutputFile=<i>/path/to/outputFile/dependencies.txt</i>
and surprise! No JSF 1.2 mentioned.
和惊喜!没有提到 JSF 1.2。
EDITForgot to add my PC setup:
编辑忘记添加我的电脑设置:
OS: Ubuntu 12.10
操作系统: Ubuntu 12.10
Eclipse: 4.2 SR1
日食:4.2 SR1
Java: jdk1.5.0_22 and jdk1.7
Java:jdk1.5.0_22 和 jdk1.7
Apache Maven: 3.0.4
Apache Maven:3.0.4
Maven home: /usr/share/maven
Maven 主页:/usr/share/maven
m2e: 1.3.1.20130219-1424
m2e:1.3.1.20130219-1424
m2e-wtp: 0.17.0.20130212-1821
m2e-wtp:0.17.0.20130212-1821
None of my co-workers are having this issue. Two of them use Windows, two use Ubuntu 12.10. One of them uses Eclipse 4.2, others use Eclipse 3.7. So apparently this is either has to do with 4.2SR1 or with my project setup. But I can't find where the problem is.
我的同事都没有这个问题。其中两个使用 Windows,两个使用 Ubuntu 12.10。其中之一使用 Eclipse 4.2,其他使用 Eclipse 3.7。很明显,这要么与 4.2SR1 有关,要么与我的项目设置有关。但是我找不到问题出在哪里。
Here's my pom.xml file:
这是我的 pom.xml 文件:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>edited</groupId>
<artifactId>edited</artifactId>
<packaging>war</packaging>
<version>edited</version>
<name>edited</name>
<distributionManagement>
<repository>
<id>deployment</id>
<name>Internal Releases</name>
<url>http://edited/nexus/content/repositories/releases/</url>
</repository>
<snapshotRepository>
<id>deployment</id>
<name>Internal Releases</name>
<url>http://edited/nexus/content/repositories/snapshots/</url>
</snapshotRepository>
</distributionManagement>
<dependencies>
<!-- Testes com Junit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
<!-- Testes Funcionais com cucumber-jvm -->
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-spring</artifactId>
<version>1.1.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
<version>1.1.1</version>
<scope>test</scope>
</dependency>
<!-- Mockito para criar mocks e stubs -->
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.9.5</version>
</dependency>
<!-- Fixture Factory Test Data Builder -->
<dependency>
<groupId>br.com.fixturefactory</groupId>
<artifactId>fixture-factory</artifactId>
<version>2.1.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<!-- Jasper Reports -->
<dependency>
<groupId>net.sf.jasperreports</groupId>
<artifactId>jasperreports</artifactId>
<version>4.5.1</version>
</dependency>
<!-- Struts 2 -->
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
<version>2.2.1.1</version>
</dependency>
<dependency>
<groupId>org.apache.struts.xwork</groupId>
<artifactId>xwork-core</artifactId>
<version>2.2.1.1</version>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-tiles-plugin</artifactId>
<version>2.2.1.1</version>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-json-plugin</artifactId>
<version>2.2.1.1</version>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-jasperreports-plugin</artifactId>
<version>2.2.1.1</version>
</dependency>
<!-- Banco de dados Mysql + Hibernate + c3p0 -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.22</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>3.3.1.GA</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-annotations</artifactId>
<version>3.4.0.GA</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-commons-annotations</artifactId>
<version>3.1.0.GA</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>4.2.0.Final</version>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.0.0.GA</version>
</dependency>
<!-- <dependency> <groupId>javax.xml.bind</groupId> <artifactId>jaxb-api</artifactId>
<version>2.2.7</version> </dependency> <dependency> <groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId> <version>2.2.6</version> </dependency> -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-c3p0</artifactId>
<version>3.6.10.Final</version>
</dependency>
<dependency>
<groupId>c3p0</groupId>
<artifactId>c3p0</artifactId>
<version>0.9.1.2</version>
</dependency>
<dependency>
<groupId>javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.3.GA</version>
</dependency>
<!-- Servlet API -->
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>servlet-api</artifactId>
<version>6.0.36</version>
</dependency>
<!-- Especifica??o do Java EE -->
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4.5</version>
</dependency>
<dependency>
<groupId>javaee</groupId>
<artifactId>javaee-api</artifactId>
<version>5</version>
<scope>provided</scope>
</dependency>
<!-- Logging -->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.2</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.2</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.2</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>1.7.2</version>
</dependency>
<!-- Apache Commons -->
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.2.1</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging-api</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>1.8.3</version>
</dependency>
<dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
<version>3.1</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.6</version>
</dependency>
<!-- Templating -->
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-core</artifactId>
<version>2.2.2</version>
</dependency>
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-api</artifactId>
<version>2.2.2</version>
</dependency>
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-jsp</artifactId>
<version>2.2.2</version>
</dependency>
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-servlet</artifactId>
<version>2.2.2</version>
</dependency>
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-template</artifactId>
<version>2.2.2</version>
</dependency>
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-compat</artifactId>
<version>2.2.2</version>
</dependency>
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker-gae</artifactId>
<version>2.3.19</version>
</dependency>
<!-- Quartz Scheduler -->
<dependency>
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz</artifactId>
<version>1.8.6</version>
</dependency>
<!-- Gera??o de Código -->
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib-nodep</artifactId>
<version>2.2.2</version>
</dependency>
<!-- Xstream -->
<dependency>
<groupId>com.thoughtworks.xstream</groupId>
<artifactId>xstream</artifactId>
<version>1.4.3</version>
</dependency>
<!-- Spring -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>3.0.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>3.0.6.RELEASE</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>3.0.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>3.0.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-spring-plugin</artifactId>
<version>2.1.8</version>
</dependency>
<!-- RestEasy -->
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jaxrs</artifactId>
<version>2.0.1.GA</version>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jaxb-provider</artifactId>
<version>2.0.1.GA</version>
</dependency>
<!-- Xfire -->
<dependency>
<groupId>org.codehaus.xfire</groupId>
<artifactId>xfire-all</artifactId>
<version>1.2.6</version>
<exclusions>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-mock</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- JQuery -->
<dependency>
<groupId>org.webjars</groupId>
<artifactId>jquery</artifactId>
<version>1.9.1</version>
</dependency>
</dependencies>
<build>
<finalName>edited</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<encoding>ISO-8859-1</encoding>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
How can I solve this?
我该如何解决这个问题?
回答by Basit
I had the same problem. After adding velocity dependencies in my maven project i was getting the same error in marker tab. Then I noticed that the web.xml file that maven project creates has servlet2.3 schema. When i changed it to servlet 3.0 schema and save the project then this error gone. Here is the web.xml file that maven creates
我有同样的问题。在我的 Maven 项目中添加速度依赖项后,我在标记选项卡中遇到了相同的错误。然后我注意到 maven 项目创建的 web.xml 文件具有 servlet2.3 架构。当我将其更改为 servlet 3.0 架构并保存项目时,此错误消失了。这是maven创建的web.xml文件
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
<display-name>Archetype Created Web Application</display-name>
</web-app>
Change it to
将其更改为
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<display-name>Archetype Created Web Application</display-name>
</web-app>
save the project, and your error would gone.
保存项目,你的错误就会消失。
回答by Anil Bharadia
I too had the same problem.
我也有同样的问题。
The solution for me was to add following in the pom.xmlas suggested here.
我的解决方案是按照此处的建议在pom.xml 中添加以下内容。
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
回答by Mangusta
I had a similar problem. I was working on a project where I did not control the web.xml configuration file, so I could not use the changes suggested about altering the version. Of course the project was not using JSF so this was especially annoying for me.
我有一个类似的问题。我正在处理一个我无法控制 web.xml 配置文件的项目,因此我无法使用建议的更改版本的更改。当然,该项目没有使用 JSF,所以这对我来说特别烦人。
I found that there is a really simple fix. Go to Preferences > Maven > Java EE Itegration and uncheck the "JSF Configurator" box.
我发现有一个非常简单的修复方法。转到 Preferences > Maven > Java EE Itegration 并取消选中“JSF Configurator”框。
I did this in a fresh workspace before importing the project again, but it may work equally as well on an existing project ... not sure.
在再次导入项目之前,我在一个新的工作区中做了这个,但它可能同样适用于现有项目......不确定。
回答by Fakher
I have encountered this with Maven projects too. This is what I had to do to get around the problem:
我在 Maven 项目中也遇到过这个问题。这是我必须做的来解决这个问题:
First update your web.xml
首先更新你的 web.xml
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<display-name>Servlet 3.0 Web Application</display-name>
Then right click on your project and select Properties -> Project Facets In there you will see the version of your Dynamic Web Module. This needs to change from version 2.3 or whatever to version 2.5 or above (I chose 3.0).
然后右键单击您的项目并选择 Properties -> Project Facets 在那里您将看到您的动态 Web 模块的版本。这需要从 2.3 版或其他版本更改为 2.5 版或更高版本(我选择了 3.0)。
However to do this I had to uncheck the tick box for Dynamic Web Module -> Apply, then do a Maven Update on the project. Go back into the Project Facets window and it should already match your web.xml configuration - 3.0 in my case. You should be able to change it if not.
但是,要做到这一点,我必须取消选中 Dynamic Web Module -> Apply 的复选框,然后对项目进行 Maven 更新。返回 Project Facets 窗口,它应该已经与您的 web.xml 配置相匹配 - 在我的情况下为 3.0。如果没有,您应该能够更改它。
If this does not work for you then try right-clicking on the Dynamic Web Module Facet and select change version (and ensure it is not locked).
如果这对您不起作用,请尝试右键单击 Dynamic Web Module Facet 并选择更改版本(并确保它没有被锁定)。
Or you can follow this steps:
或者您可以按照以下步骤操作:
- Window > Show View > Other > General > navigator
- There is a .settings folder under your project directory
- Change the dynamic web module version in this line to 3.0
- Change the Java version in this line to 1.5 or higher
- 窗口 > 显示视图 > 其他 > 常规 > 导航器
- 您的项目目录下有一个 .settings 文件夹
- 将此行中的动态web模块版本更改为3.0
- 将此行中的 Java 版本更改为 1.5 或更高
don't forget to update your project
不要忘记更新您的项目
Hope that works!
希望有效!
回答by BrianHenryIE
After changing lots in my POM and updating my JDK I was getting the "One or more constraints have not been satisfied" related to Google App Engine. The solution was to delete the Eclipse project settings and reimport it.
在我的 POM 中更改了很多并更新了我的 JDK 后,我得到了与 Google App Engine 相关的“一个或多个约束条件没有得到满足”。解决方案是删除 Eclipse 项目设置并重新导入它。
On OS X, I did this in Terminal by changing to the project directory and
在 OS X 上,我在终端中通过更改到项目目录和
rm -rf .project
rm -rf .settings
回答by Arvind Panwar
Eclipse is buggy on factes screen and at times doesn't update the config files in workspace. There are two options one can try :
Eclipse 在事实屏幕上有问题,有时不会更新工作区中的配置文件。有两种选择可以尝试:
Go to org.eclipse.wst.common.project.facet.core.xml file located inside .settings folder of eclipse project. Go and manually delete the JSF facet entry. you can also update other facets as well.
Right click project and go to properties->Maven-->Java EE Integeration. choose options : enable project specific settings, Enable Java EE configuration, Maven archiver generates files under the build directory
转到位于 eclipse 项目的 .settings 文件夹内的 org.eclipse.wst.common.project.facet.core.xml 文件。去手动删除 JSF facet 条目。您还可以更新其他方面。
右键单击项目并转到属性->Maven-->Java EE Integeration。选择选项:启用项目特定设置,启用 Java EE 配置,Maven 归档器在 build 目录下生成文件
回答by Torsten
You should check your project facets in the project configuration. This is where you may uncheck the JSF dependency.
您应该在项目配置中检查您的项目方面。您可以在此处取消选中 JSF 依赖项。
回答by m2lit
The m2e plugin generate project configuration every time when you update project (Maven->Update Project ... That action overrides facets setting configured manually in Eclipse. Therefore you have to configure it on pom level. By setting properties in pom file you can tell m2e plugin what to do.
每次更新项目时,m2e 插件都会生成项目配置(Maven->更新项目...该操作会覆盖在 Eclipse 中手动配置的 facets 设置。因此您必须在 pom 级别配置它。通过在 pom 文件中设置属性,您可以知道m2e插件做什么。
Enable/Disable the JAX-RS/JPA/JSF Configurators at the pom.xml level The optional JAX-RS, JPA and JSF configurators can be enabled or disabled at a workspace level from Window > Preferences > Maven > Java EE Integration. Now, you can have a finer grain control on these configurators directly from your pom.xml properties :
在 pom.xml 级别启用/禁用 JAX-RS/JPA/JSF 配置器可以在工作区级别从“窗口”>“首选项”>“Maven”>“Java EE 集成”启用或禁用可选的 JAX-RS、JPA 和 JSF 配置器。现在,您可以直接从 pom.xml 属性对这些配置器进行更精细的控制:
Adding false in your pom properties section will disable the JAX-RS configurator Adding false in your pom properties section will disable the JPA configurator Adding false in your pom properties section will disable the JSF configurator The pom settings always override the workspace preferences. So if you have, for instance the JPA configurator disabled at the workspace level, using true will enable it on your project anyway. (http://wiki.eclipse.org/M2E-WTP/New_and_Noteworthy/1.0.0)
在 pom 属性部分添加 false 将禁用 JAX-RS 配置器在 pom 属性部分添加 false 将禁用 JPA 配置器在 pom 属性部分添加 false 将禁用 JSF 配置器 pom 设置始终覆盖工作区首选项。因此,例如,如果您在工作区级别禁用了 JPA 配置器,那么无论如何使用 true 都会在您的项目中启用它。( http://wiki.eclipse.org/M2E-WTP/New_and_Noteworthy/1.0.0)
回答by VYSAKHAN SREEKUMARAN KASTHURI
The below steps should be the simple fix to your problem
以下步骤应该是解决您问题的简单方法
- Project->Properties->ProjectFacet-->Uncheck jsf apply and OK.
- Project->Maven->UpdateProject-->This will solve the issue.
- Project->Properties->ProjectFacet-->取消勾选jsf apply就OK了。
- Project->Maven->UpdateProject-->这将解决问题。
Here while on Updating Project Maven will automatically chooses the Dynamic web module
这里在更新项目时 Maven 将自动选择动态 web 模块
回答by Soufiane ELH
the same solution as Basit.. but the version 3.0 doesn't work for metry this .. it works for me to integrate struts 2.x
与Basit相同的解决方案.. 但3.0 版对我不起作用试试这个 ..集成 struts 2.x 对我有用
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>blabla</display-name>
...
</web-app>