我正在使用maven在Eclipse中创建一个动态web应用程序。我添加了一些文件夹,如src/test/java和src/test/resources。我还更改了Java Build Path中的库,以获得JavaSE-1.7。到这里都没问题。
当我试图改变项目Facet动态Web模块时,出了问题。在同一个地方,我将Java更改为1.7。它仍然告诉我,不能将项目facet动态Web模块的版本更改为3.0。
我已经改变了所有我认为会影响改变的东西。
我正在使用maven在Eclipse中创建一个动态web应用程序。我添加了一些文件夹,如src/test/java和src/test/resources。我还更改了Java Build Path中的库,以获得JavaSE-1.7。到这里都没问题。
当我试图改变项目Facet动态Web模块时,出了问题。在同一个地方,我将Java更改为1.7。它仍然告诉我,不能将项目facet动态Web模块的版本更改为3.0。
我已经改变了所有我认为会影响改变的东西。
当前回答
请打开Navigator视图并执行以下步骤
(Window > Show View > Other > General),然后发现在你的项目下有一个。settings文件夹,展开它,然后打开文件“org.eclipse.wst.common.project.facet.core.xml”,做下面的修改并保存文件。 将这一行中的动态web模块版本更改为2.5 - 将这一行中的Java版本更改为1.5或更高版本。
其他回答
Click on your project folder. Go to Window > Show View > Navigator Go to Navigator and expand the .settings folder Open org.eclipse.wst.common.project.facet.core.xml file <?xml version="1.0" encoding="UTF-8"?> <faceted-project> <fixed facet="wst.jsdt.web"/> <installed facet="jst.web" version="2.3"/> <installed facet="wst.jsdt.web" version="1.0"/> <installed facet="java" version="1.8"/> </faceted-project> Change the version like this <installed facet="jst.web" version="3.1"/> Save Just update your project. Right Click on The Project Folder > Maven > Update Project > Select the Project and click 'Ok'
这招对我很管用。
如果悉尼的回答仍然没有帮助,那么试试下面的答案。 按照悉尼的答案,去属性>项目facet取消选择动态Web模块,然后改变版本以匹配您的网页。配置,然后再次选择。应用>保存 然后是Maven更新。
web . xml
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:web="http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
id="Web_App_1" version="3.1">
<display-name>JavaServerFaces</display-name>
<!-- Change to "Production" when you are ready to deploy -->
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<!-- Welcome page -->
<welcome-file-list>
<welcome-file>jsfs/hello.xhtml</welcome-file>
</welcome-file-list>
<!-- JSF mapping -->
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<!-- Map these files with JSF -->
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>jsfs/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.faces</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
右键单击项目→属性;在Project Facets中,取消选择Dynamic Web Module(版本应为3.1)和JavaServer Faces(版本应为2.2)。
改变:
<web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" 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">
:
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:javaee="http://xmlns.jcp.org/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
然后删除param-name等前面的前缀。
最后,Maven ->更新项目。
对我有用的是:
将Java更改为1.8(或1.7)
在你的POM中-你必须在<build>节中将编译器插件设置为1.8(或1.7)版本:
<build>
...
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
确保更改Java Build显示为1.8。如果没有,单击编辑并选择它应该是什么。
修改web.xml,以便在版本和链接中引用3.0
确保在Project Facets中将Java设置为1.8
在这个阶段,我仍然不能改变动态Web模块;
而不是改变它:
a)取消勾选动态Web模块
b)应用
C)再检查一遍。新版本3.0应该设置。**
应用并再次检查后:
希望这能有所帮助。
这个问题与版本右键单击项目->属性->项目Facets->右键单击动态Web模块->解锁它-> uncheck->选择2.5版本->应用->更新maven