解决Cannot change version of project facet Dynamic web module to 2.5

简介: <p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; font-family:Arial; font-size:14px; line-height:26px"> 原文地址:<a target="_blank" href="http://blog.csdn.net/steveguo

原文地址:http://blog.csdn.net/steveguoshao/article/details/38414145

我们用Eclipse创建Maven结构的web项目的时候选择了Artifact Id为maven-artchetype-webapp,由于这个catalog比较老,用的servlet还是2.3的,而一般现在至少都是2.5,在Project Facets里面修改Dynamic web module为2.5的时候就会出现Cannot change version of project facet Dynamic web module to 2.5,如图:


其实在右边可以看到改到2.5需要的条件以及有冲突的facets,解决这个问题的步骤如下:

1.把Servlet改成2.5,打开项目的web.xml,改之前:

[html]  view plain  copy
 print ? 在CODE上查看代码片 派生到我的代码片
  1. <!DOCTYPE web-app PUBLIC  
  2.  "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"  
  3.  "http://java.sun.com/dtd/web-app_2_3.dtd" >  
  4.   
  5. <web-app>  
  6.   <display-name>Archetype Created Web Application</display-name>  
  7. </web-app>  


改后:

[html]  view plain  copy
 print ? 在CODE上查看代码片 派生到我的代码片
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <web-app version="2.5"  
  3.     xmlns="http://java.sun.com/xml/ns/javaee"  
  4.     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
  5.     xsi:schemaLocation="http://java.sun.com/xml/ns/javaee  
  6.     http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">  
  7.       
  8.   <display-name>Archetype Created Web Application</display-name>  
  9. </web-app>  


2.修改项目的设置,在Navigator下打开项目.settings目录下的org.eclipse.jdt.core.prefs

[html]  view plain  copy
 print ? 在CODE上查看代码片 派生到我的代码片
  1. eclipse.preferences.version=1  
  2. org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled  
  3. org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5  
  4. org.eclipse.jdt.core.compiler.compliance=1.5  
  5. org.eclipse.jdt.core.compiler.problem.assertIdentifier=error  
  6. org.eclipse.jdt.core.compiler.problem.enumIdentifier=error  
  7. org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning  
  8. org.eclipse.jdt.core.compiler.source=1.5  

把1.5改成1.6

[html]  view plain  copy
 print ? 在CODE上查看代码片 派生到我的代码片
  1. eclipse.preferences.version=1  
  2. org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled  
  3. org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6  
  4. org.eclipse.jdt.core.compiler.compliance=1.6  
  5. org.eclipse.jdt.core.compiler.problem.assertIdentifier=error  
  6. org.eclipse.jdt.core.compiler.problem.enumIdentifier=error  
  7. org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning  
  8. org.eclipse.jdt.core.compiler.source=1.6  

打开org.eclipse.wst.common.component

[html]  view plain  copy
 print ? 在CODE上查看代码片 派生到我的代码片
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <project-modules id="moduleCoreId" project-version="1.5.0">  
  3.     <wb-module deploy-name="test">  
  4.         <wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>  
  5.         <wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>  
  6.         <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>  
  7.         <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>  
  8.         <property name="context-root" value="test"/>  
  9.         <property name="java-output-path" value="/test/target/classes"/>  
  10.     </wb-module>  
  11. </project-modules>  

project-version="1.5.0"改成 project-version="1.6.0"

[html]  view plain  copy
 print ? 在CODE上查看代码片 派生到我的代码片
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <project-modules id="moduleCoreId" project-version="1.6.0">  
  3.     <wb-module deploy-name="test">  
  4.         <wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>  
  5.         <wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>  
  6.         <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>  
  7.         <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>  
  8.         <property name="context-root" value="test"/>  
  9.         <property name="java-output-path" value="/test/target/classes"/>  
  10.     </wb-module>  
  11. </project-modules>  

打开org.eclipse.wst.common.project.facet.core.xml

[html]  view plain  copy
 print ? 在CODE上查看代码片 派生到我的代码片
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <faceted-project>  
  3.   <fixed facet="wst.jsdt.web"/>  
  4.   <installed facet="java" version="1.5"/>  
  5.   <installed facet="jst.web" version="2.3"/>  
  6.   <installed facet="wst.jsdt.web" version="1.0"/>  
  7. </faceted-project>  

把<installed facet="java" version="1.5"/>改成<installed facet="java" version="1.6"/>,把  <installed facet="jst.web" version="2.3"/>改成  <installed facet="jst.web" version="2.5"/>

[html]  view plain  copy
 print ? 在CODE上查看代码片 派生到我的代码片
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <faceted-project>  
  3.   <fixed facet="wst.jsdt.web"/>  
  4.   <installed facet="java" version="1.6"/>  
  5.   <installed facet="jst.web" version="2.5"/>  
  6.   <installed facet="wst.jsdt.web" version="1.0"/>  
  7. </faceted-project>  

都改好之后在打开看看,已经把Dynamic web module改成了2.5



好了,大功搞成,这是一种解决办法,但是治标不治本,更高级的就是自定义catalog,然后安装到本地,再创建的时候啥都有了,比如把现在流行的s(struts2)sh,ssi,s(springmvc)sh 创建catalog,包括包结构,部分代码啥的都有,下次写吧。

目录
相关文章
|
Python
python2 pip2 No module named web
python2 pip2 No module named web
97 0
|
Android开发
web project导入eclipse ,针对run as里 没有 run on server 选项问题?
web project导入eclipse ,针对run as里 没有 run on server 选项问题?
664 0
web project导入eclipse ,针对run as里 没有 run on server 选项问题?
|
前端开发 JavaScript 安全
【Web 前端】怎么实现Module模块化?
【5月更文挑战第1天】【Web 前端】怎么实现Module模块化?
|
Java Maven
IntelliJ IDEA 新建/创建Maven Web项目Project
IntelliJ IDEA 新建/创建Maven Web项目Project
128 0
|
存储 关系型数据库 MySQL
cannot load "mso.dll" vs2008 web开发问题
​已成功解决办法:①将VS 2008安装包WCUWebDesignerCoreWebDesignerCore.exe提取并重新安装;②将C:Program Files/Common Files/Microsoft Shared/OFFICE12/Office Setup Controller路径下的Setup.exe文件更名或删除。32位、64位存储不一样 Program Files没有就去...
103 0
cannot load "mso.dll" vs2008 web开发问题
|
Python
python2 pip2 pip install web.py No module named wsgiserver
python2 pip2 pip install web.py No module named wsgiserver
108 0
|
前端开发 Java Maven
项目web.xml中配置DispatcherServlet时,红色波浪线报错(Cannot resolve Servlet ‘DispatcherServlet‘)
项目web.xml中配置DispatcherServlet时,红色波浪线报错(Cannot resolve Servlet ‘DispatcherServlet‘)
|
XML Java 应用服务中间件
怒赞!The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml解决方案
怒赞!The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml解决方案
198 0
怒赞!The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml解决方案
|
Java Maven
使用maven构建项目报错Cannot change version of project facet Dynamic Web Module to 3.0解决方案
使用maven构建项目报错Cannot change version of project facet Dynamic Web Module to 3.0解决方案
使用maven构建项目报错Cannot change version of project facet Dynamic Web Module to 3.0解决方案
|
应用服务中间件
Cannot change version of project facet Dynamic Web Module to 3.0
Cannot change version of project facet Dynamic Web Module to 3.0
120 0