Cannot change version of project facet Dynamic web 3.0的解決方法

轉載自:https://www.cnblogs.com/strinkbug/p/4939299.htmlhtml

問題java

 用Eclipse建立Maven結構的web項目的時候選擇了Artifact Id爲maven-artchetype-webapp,因爲這個catalog比較老,用的servlet仍是2.3的,而通常如今都是用3.0,在Project Facets裏面修改Dynamic web module爲3.0的時候就會出現Cannot change version of project facet Dynamic web module to 3.0web

 

解決這個問題的步驟以下:app

1. 把Servlet改爲3.0,打開項目的web.xml
<? xml  version = "1.0"  encoding = "UTF-8" ?>
< web-app  xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
     xmlns = "http://java.sun.com/xml/ns/javaee"
     xsi:schemaLocation = "http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
     id = "schedule-console"  version = "3.0" >

2. 修改項目的設置,在Navigator下打開項目.settings目錄下的org.eclipse.jdt.core.prefs
把1.5改爲1.8
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.source=1.8
 
 
3. 打開org.eclipse.wst.common.project.facet.core.xml 
把java改成1.8, 把jst.web改成3.0;
<? 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.8" />
</ faceted-project >

 

最後 update maven就能夠了,親測有效。
相關文章
相關標籤/搜索