解决Cannot change version of project facet Dynamic
2015-06-24 00:00
423 查看
我们用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 plaincopyprint?
改后:
[html] view plaincopyprint?
2.修改项目的设置,在Navigator下打开项目.settings目录下的org.eclipse.jdt.core.prefs
[html] view plaincopyprint?
把1.5改成1.6
[html] view plaincopyprint?
打开org.eclipse.wst.common.component
[html] view plaincopyprint?
把project-version="1.5.0"改成project-version="1.6.0"
[html] view plaincopyprint?
打开org.eclipse.wst.common.project.facet.core.xml
[html] view plaincopyprint?
把<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 plaincopyprint?
都改好之后在打开看看,已经把Dynamic web module改成了2.5
好了,大功搞成,这是一种解决办法,但是治标不治本,更高级的就是自定义catalog,然后安装到本地,再创建的时候啥都有了,比如把现在流行的s(struts2)sh,ssi,s(springmvc)sh 创建catalog,包括包结构,部分代码啥的都有,下次写吧。
其实在右边可以看到改到2.5需要的条件以及有冲突的facets,解决这个问题的步骤如下:
1.把Servlet改成2.5,打开项目的web.xml,改之前:
[html] view plaincopyprint?
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd" > <web-app> <display-name>Archetype Created Web Application</display-name> </web-app>
改后:
[html] view plaincopyprint?
<?xml version="1.0" encoding="UTF-8"?> <web-app version="2.5" 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_2_5.xsd"> <display-name>Archetype Created Web Application</display-name> </web-app>
2.修改项目的设置,在Navigator下打开项目.settings目录下的org.eclipse.jdt.core.prefs
[html] view plaincopyprint?
eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 org.eclipse.jdt.core.compiler.compliance=1.5 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.5
把1.5改成1.6
[html] view plaincopyprint?
eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 org.eclipse.jdt.core.compiler.compliance=1.6 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.6
打开org.eclipse.wst.common.component
[html] view plaincopyprint?
<?xml version="1.0" encoding="UTF-8"?> <project-modules id="moduleCoreId" project-version="1.5.0"> <wb-module deploy-name="test"> <wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/> <wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/> <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/> <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/> <property name="context-root" value="test"/> <property name="java-output-path" value="/test/target/classes"/> </wb-module> </project-modules>
把project-version="1.5.0"改成project-version="1.6.0"
[html] view plaincopyprint?
<?xml version="1.0" encoding="UTF-8"?> <project-modules id="moduleCoreId" project-version="1.6.0"> <wb-module deploy-name="test"> <wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/> <wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/> <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/> <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/> <property name="context-root" value="test"/> <property name="java-output-path" value="/test/target/classes"/> </wb-module> </project-modules>
打开org.eclipse.wst.common.project.facet.core.xml
[html] view plaincopyprint?
<?xml version="1.0" encoding="UTF-8"?> <faceted-project> <fixed facet="wst.jsdt.web"/> <installed facet="java" version="1.5"/> <installed facet="jst.web" version="2.3"/> <installed facet="wst.jsdt.web" version="1.0"/> </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 plaincopyprint?
<?xml version="1.0" encoding="UTF-8"?> <faceted-project> <fixed facet="wst.jsdt.web"/> <installed facet="java" version="1.6"/> <installed facet="jst.web" version="2.5"/> <installed facet="wst.jsdt.web" version="1.0"/> </faceted-project>
都改好之后在打开看看,已经把Dynamic web module改成了2.5
好了,大功搞成,这是一种解决办法,但是治标不治本,更高级的就是自定义catalog,然后安装到本地,再创建的时候啥都有了,比如把现在流行的s(struts2)sh,ssi,s(springmvc)sh 创建catalog,包括包结构,部分代码啥的都有,下次写吧。
相关文章推荐
- 责任链模式(Chain of Responsibility)的标准版
- MyEclipse Web Project转Eclipse Dynamic Web Project
- centos 手动安装网卡驱动
- DLL(Dynamic Linkable Library) 详解说明
- 深入C# 4.0 新特性dynamic、可选参数、命名参数的详细介绍
- Validation of viewstate MAC failed.的解决方法
- jquery中change()用法实例分析
- C# Dynamic关键字之:解析dynamic就是Object
- C# Dynamic关键字之:dynamic为什么比反射快的详解
- Some tips of wmi scripting in jscript (1)
- C# dynamic关键字的使用方法
- PHP Warning: PHP Startup: Unable to load dynamic library \ D:/php5/ext/php_mysqli.dll\
- Display SQL Server Version Information
- js change,propertychange,input事件小议
- javascript的onchange事件与jQuery的change()方法比较
- Java设计模式之责任链模式(Chain of Responsibility模式)介绍
- Python version 2.7 required, which was not found in the registry
- 代码规范及CodeReview要点
- RDM 与Project 的对比分析报告