eclipse project and java resources report error but can run

This error is generally a jdk version problem. There are solutions on many posts. If you confirm that jdk is no problem, you can try the following method

Reprinted from: http://blog.csdn.net/sy793314598/article/details/77529040


Reason: When using Eclipse to create a web project with a Maven structure, the Artifact Id was selected as maven-artchetype-webapp. Since this catalog is relatively old, the servlet used is still 2.3, but it is generally at least 2.5 now. Modify Dynamic in Project Facets When the web module is 2.5, Cannot change version of project facet Dynamic web module to 2.5 will appear, as shown in the figure:

First right-click on the error file:

Find Porject Facets and change the Dynamic Web Module version to 2.5.


It seems to be very simple, but it is often not allowed to modify it at this time. Before we modify it, we have to do some preparations. So, what preparations do you need to do?

First, open the web.xml of the project and change the Servlet to 2.5

Before modification:

[html]  view plain  copy
  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>    

after modification:

[html]  view plain  copy
  1. <web-appversion="2.5"    
  2.     xmlns="http://java.sun.com/xml/ns/javaee"   
  3.     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"   
  4.     xsi:schemaLocation="http://java.sun.com/xml/ns/javaee   
  5.     http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">  

Second, modify the settings of the project, open org.eclipse.jdt.core.prefs in the project .settings directory under Navigator





change into

[html]  view plain  copy
  1. eclipse.preferences.version=1  
  2. org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled  
  3. org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7  
  4. org.eclipse.jdt.core.compiler.compliance=1.7  
  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.7  

打开org.eclipse.wst.common.component,将project-version修改为1.7.0

[html]  view plain  copy
  1. <?xml version="1.0" encoding="UTF-8"?>    
  2. <project-modules id="moduleCoreId" project-version="1.7.0">    

打开org.eclipse.wst.common.project.facet.core.xml,修改

[html]  view plain  copy
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <faceted-project>  
  3.   <fixed facet="wst.jsdt.web"/>  
  4.   <installed facet="wst.jsdt.web" version="1.0"/>  
  5.   <installedfacet="java"version="1.7"/>    
  6.   <installedfacet="jst.web"version="2.5"/>    
  7.   <installedfacet="jst.jaxrs"version="1.1"/>    
  8.   <installedfacet="jst.jsf"version="2.0"/>    
  9. </faceted-project>  

Ok, the preparations are complete, open it again to see if the Dynamic web module has been changed to 2.5


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325956391&siteId=291194637