使用Java Server Faces 1.2的Maven Java EE配置标记

时间:2023-01-25 14:33:30

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,没有任何错误,但是Marker选项卡始终显示以下消息:

[-] 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提到。

EDIT Forgot to add my PC setup:

编辑忘记添加我的PC设置:

OS: Ubuntu 12.10

操作系统:Ubuntu 12.10

Eclipse: 4.2 SR1

Eclipse: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:

这是我的砰的一声。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?

我怎么解决这个问题?

11 个解决方案

#1


41  

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项目中添加速度依赖项之后,我在marker选项卡中得到了相同的错误。然后我注意到网络。maven项目创建的xml文件具有servlet2.3模式。当我将它更改为servlet 3.0模式并保存项目时,这个错误就消失了。这是网络。maven创建的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.

保存项目,您的错误就会消失。

#2


16  

I too had the same problem.

我也有同样的问题。

The solution for me was to add following in the pom.xml as 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>

#3


10  

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.

我也有类似的问题。我当时正在做一个项目,在那里我不能控制网络。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配置程序”框。

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.

在再次导入项目之前,我在一个新的工作空间中进行了此操作,但是对于一个现有的项目来说,它可能同样有效……不确定。

#4


8  

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 ->项目facet,您将看到动态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.

然而,为了做到这一点,我必须取消动态Web模块的勾选框->应用,然后在项目上做一个Maven更新。回到Project facet窗口,它应该已经与您的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).

如果这对您不起作用,那么尝试右键单击动态Web模块方面并选择change version(并确保它没有被锁定)。

Or you can follow this steps:

或者你可以遵循以下步骤:

  1. Window > Show View > Other > General > navigator
  2. 窗口>显示查看>其他>通用>导航器
  3. There is a .settings folder under your project directory
  4. 项目目录下有一个.settings文件夹
  5. Change the dynamic web module version in this line to 3.0
  6. 将这一行中的动态web模块版本更改为3.0
  7. Change the Java version in this line to 1.5 or higher
  8. 将本行中的Java版本更改为1.5或更高

don't forget to update your project

不要忘记更新你的项目

Hope that works!

希望工程!

#5


4  

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之后,我得到了与谷歌应用引擎相关的“一个或多个约束未被满足”。解决方案是删除Eclipse项目设置并重新导入它。

On OS X, I did this in Terminal by changing to the project directory and

在OS X上,我在终端上通过更改项目目录和

rm -rf .project
rm -rf .settings

#6


2  

You should check your project facets in the project configuration. This is where you may uncheck the JSF dependency.

您应该在项目配置中检查项目方面。您可以在这里取消对JSF依赖项的检查。

使用Java Server Faces 1.2的Maven Java EE配置标记

#7


2  

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中手动配置的facet设置。因此,您必须在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上启用/禁用JAX-RS/JPA/JSF配置程序。xml级别的可选JAX-RS、JPA和JSF配置器可以在窗口>首选项> Maven > Java EE集成的工作空间级别上启用或禁用。现在,你可以直接从你的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将禁用在pom属性部分添加false的JPA配置程序将禁用JSF配置程序pom设置总是覆盖工作区首选项。因此,如果您在工作空间级别禁用了JPA配置程序,那么无论如何,使用true都会在项目中启用它。(http://wiki.eclipse.org/M2E-WTP/New_and_Noteworthy/1.0.0)

#8


1  

Eclipse is buggy on factes screen and at times doesn't update the config files in workspace. There are two options one can try :

在factes屏幕上,Eclipse存在bug,并且有时不会更新工作空间中的配置文件。有两种选择:

  1. 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.

    Go to org.eclipse.wst.common.project.facet.core.xml文件位于eclipse项目的.settings文件夹内。手动删除JSF facet条目。您还可以更新其他方面。

  2. 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

    右键单击项目,进入属性->Maven- >Java EE Integeration。选择选项:启用项目特定设置,启用Java EE配置,Maven归档程序在构建目录下生成文件

#9


0  

the same solution as Basit .. but the version 3.0 doesn't work for me try 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>

#10


0  

This is an older thread,but I will post my answer for others. I have to recreate the project in a different workspace after the changes to make it work, as discussed in JavaServer Faces 2.2 requires Dynamic Web Module 2.5 or newer

这是一个旧的线程,但是我将为其他人发布我的答案。在更改之后,我必须在另一个工作区中重新创建项目以使其工作,如在JavaServer Faces 2.2中讨论的那样,需要动态Web模块2.5或更新

#11


0  

The below steps should be the simple fix to your problem

下面的步骤应该是解决问题的简单方法

  1. Project->Properties->ProjectFacet-->Uncheck jsf apply and OK.
  2. 项目->属性->ProjectFacet- >Uncheck jsf应用和OK。
  3. Project->Maven->UpdateProject-->This will solve the issue.
  4. 项目->Maven->UpdateProject- >这将解决这个问题。

Here while on Updating Project Maven will automatically chooses the Dynamic web module

在这里更新项目时,Maven将自动选择动态web模块

#1


41  

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项目中添加速度依赖项之后,我在marker选项卡中得到了相同的错误。然后我注意到网络。maven项目创建的xml文件具有servlet2.3模式。当我将它更改为servlet 3.0模式并保存项目时,这个错误就消失了。这是网络。maven创建的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.

保存项目,您的错误就会消失。

#2


16  

I too had the same problem.

我也有同样的问题。

The solution for me was to add following in the pom.xml as 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>

#3


10  

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.

我也有类似的问题。我当时正在做一个项目,在那里我不能控制网络。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配置程序”框。

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.

在再次导入项目之前,我在一个新的工作空间中进行了此操作,但是对于一个现有的项目来说,它可能同样有效……不确定。

#4


8  

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 ->项目facet,您将看到动态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.

然而,为了做到这一点,我必须取消动态Web模块的勾选框->应用,然后在项目上做一个Maven更新。回到Project facet窗口,它应该已经与您的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).

如果这对您不起作用,那么尝试右键单击动态Web模块方面并选择change version(并确保它没有被锁定)。

Or you can follow this steps:

或者你可以遵循以下步骤:

  1. Window > Show View > Other > General > navigator
  2. 窗口>显示查看>其他>通用>导航器
  3. There is a .settings folder under your project directory
  4. 项目目录下有一个.settings文件夹
  5. Change the dynamic web module version in this line to 3.0
  6. 将这一行中的动态web模块版本更改为3.0
  7. Change the Java version in this line to 1.5 or higher
  8. 将本行中的Java版本更改为1.5或更高

don't forget to update your project

不要忘记更新你的项目

Hope that works!

希望工程!

#5


4  

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之后,我得到了与谷歌应用引擎相关的“一个或多个约束未被满足”。解决方案是删除Eclipse项目设置并重新导入它。

On OS X, I did this in Terminal by changing to the project directory and

在OS X上,我在终端上通过更改项目目录和

rm -rf .project
rm -rf .settings

#6


2  

You should check your project facets in the project configuration. This is where you may uncheck the JSF dependency.

您应该在项目配置中检查项目方面。您可以在这里取消对JSF依赖项的检查。

使用Java Server Faces 1.2的Maven Java EE配置标记

#7


2  

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中手动配置的facet设置。因此,您必须在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上启用/禁用JAX-RS/JPA/JSF配置程序。xml级别的可选JAX-RS、JPA和JSF配置器可以在窗口>首选项> Maven > Java EE集成的工作空间级别上启用或禁用。现在,你可以直接从你的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将禁用在pom属性部分添加false的JPA配置程序将禁用JSF配置程序pom设置总是覆盖工作区首选项。因此,如果您在工作空间级别禁用了JPA配置程序,那么无论如何,使用true都会在项目中启用它。(http://wiki.eclipse.org/M2E-WTP/New_and_Noteworthy/1.0.0)

#8


1  

Eclipse is buggy on factes screen and at times doesn't update the config files in workspace. There are two options one can try :

在factes屏幕上,Eclipse存在bug,并且有时不会更新工作空间中的配置文件。有两种选择:

  1. 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.

    Go to org.eclipse.wst.common.project.facet.core.xml文件位于eclipse项目的.settings文件夹内。手动删除JSF facet条目。您还可以更新其他方面。

  2. 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

    右键单击项目,进入属性->Maven- >Java EE Integeration。选择选项:启用项目特定设置,启用Java EE配置,Maven归档程序在构建目录下生成文件

#9


0  

the same solution as Basit .. but the version 3.0 doesn't work for me try 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>

#10


0  

This is an older thread,but I will post my answer for others. I have to recreate the project in a different workspace after the changes to make it work, as discussed in JavaServer Faces 2.2 requires Dynamic Web Module 2.5 or newer

这是一个旧的线程,但是我将为其他人发布我的答案。在更改之后,我必须在另一个工作区中重新创建项目以使其工作,如在JavaServer Faces 2.2中讨论的那样,需要动态Web模块2.5或更新

#11


0  

The below steps should be the simple fix to your problem

下面的步骤应该是解决问题的简单方法

  1. Project->Properties->ProjectFacet-->Uncheck jsf apply and OK.
  2. 项目->属性->ProjectFacet- >Uncheck jsf应用和OK。
  3. Project->Maven->UpdateProject-->This will solve the issue.
  4. 项目->Maven->UpdateProject- >这将解决这个问题。

Here while on Updating Project Maven will automatically chooses the Dynamic web module

在这里更新项目时,Maven将自动选择动态web模块