您的位置:首页 > 其它

Maven创建web工程报错

2016-03-05 18:55 232 查看
1.Error: cannot change version of project facet dynamic web module to 3.0

1.1 修改web.xml

<?xml version="1.0" encoding="UTF-8"?>

<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>
</web-app>


1.2 找到工程目录,修改.setting/org.eclipse.wst.common.project.facet.core.xml文件

<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
<fixed facet="wst.jsdt.web"/>
<installed facet="jst.web" version="3.0"/>
<installed facet="wst.jsdt.web" version="1.0"/>
<installed facet="java" version="1.7"/>
<installed facet="jst.jsf" version="2.2"/>
<installed facet="jst.jaxrs" version="2.0"/>
</faceted-project>

直接手动修改jst.web对应的version即可。

然后,项目右键-->Maven-->Update Project

2.Error: JavaServer Faces 2.2 can not be installed : One or more constraints have not been satisfied

修改web.xml文件

<?xml version="1.0" encoding="UTF-8"?>

<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>
</web-app>

3.Error: JAX-RS (REST Web Services) 2.0 can not be installed : One or more constraints have not been satisfied

修改pom.xml文件,在<build>中加入如下语句。

<build>
<finalName>mvntest</finalName>

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

以上问题经常同时出现,暴力一点,把文件都改了,就没问题了。至于问题出现的原因,还没有深层的追究,希望各位大神能指点一下。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: