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

我们用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?

  1. "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" 
  2. "http://java.sun.com/dtd/web-app_2_3.dtd" >
  3. Archetype Created Web Application

改后:

[html] view plaincopyprint?

  1. xmlns="http://java.sun.com/xml/ns/javaee"
  2. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  3. xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
  4.     http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
  5. Archetype Created Web Application

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

[html] view plaincopyprint?

  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 plaincopyprint?

  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 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?

改成,把  改成 

[html] view plaincopyprint?

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

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

转载于:https://www.cnblogs.com/wych/p/4610583.html

你可能感兴趣的:(开发工具,java,web.xml)