Cannot change version of project facet Dynamic Web Module to 3.0?

来源:互联网 发布:mysql 配置用户名密码 编辑:程序博客网 时间:2024/06/05 15:09

转载:http://stackoverflow.com/questions/18122336/cannot-change-version-of-project-facet-dynamic-web-module-to-3-0


1.

This Problem With version right click on the project->properties->Project Facets->right click on Dynamic Web Module->unlock it-> uncheck->select 2.5 version->Apply->Update the maven


2.

This is a variation on pagurix's answer, but using Eclipse Mars.

Change your web.xml file to web.bak

Ignore the errors, we'll regenerate it next.

Go into project properties -> project facets and set the Dynamic Web Module version to what you need. Eclipse now allows you to save.

Now right-click on the project. Choose Java EE Tools -> Generate Deployment Descriptor Stub.

This creates a new web.xml with the required version.

Open the new web.xml and copy across the XML header and the complete web-app opening tag to your original web.bak, delete the new web.xml and rename web.bak back to web.xml.

Done.


3. 参考http://blog.csdn.net/penker_zhao/article/details/40589375

If you want to use version 3.1 you need to use the following schema:

  • http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd

Note that 3.0 and 3.1 are different: in 3.1 there's no Sun mentioned, so simply changing 3_0.xsd to 3_1.xsd won't work

<?xml version="1.0" encoding="UTF-8"?><web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee                 http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"         version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee"></web-app>

Also, make sure you're depending on the latest versions in your pom.xml. That is,

<plugin>    <groupId>org.apache.maven.plugins</groupId>    <artifactId>maven-war-plugin</artifactId>    <version>2.4</version>    <configuration>        ...    </configuration></plugin>

and

<dependency>    <groupId>javax.servlet</groupId>    <artifactId>javax.servlet-api</artifactId>    <version>3.1.0</version>    <scope>provided</scope></dependency>

Also, you should compile with Java 7 or 8:

<plugin>    <groupId>org.apache.maven.plugins</groupId>    <artifactId>maven-compiler-plugin</artifactId>    <version>3.1</version>    <configuration>        <source>1.7</source>        <target>1.7</target>    </configuration></plugin>


0 0
原创粉丝点击