Eclipse EE 4.7.3环境下无法设置Dynamic Web Project版本为4.0如何解决?
Fixing Dynamic Web Module 4.0 Support in Eclipse EE 4.7.3 (Oxygen)
Hey there, let’s tackle this issue step by step. The root cause here is that Eclipse EE 4.7.3 (Oxygen) doesn’t natively support Servlet 4.0 (which maps to Dynamic Web Module 4.0) — that support was added starting with Eclipse Photon (4.8). But don’t worry, we’ve got two solid ways to get this working with your current setup:
Option 1: Install the Servlet 4.0 Support Update for Eclipse Oxygen
This is the cleanest approach, as it adds official support directly to your Eclipse instance:
- Open Eclipse, head to
Help > Install New Software - In the "Work with" dropdown, select the Oxygen update site:
http://download.eclipse.org/releases/oxygen - Search for
Web, XML, Java EE and OSGi Enterprise Developmentand expand this category - Look for the
Servlet 4.0 Supportfeature (it’s usually nested under theEclipse Java EE Developer Toolssubcategory) - Check the box next to it, click
Next, and follow the prompts to complete the installation - Restart Eclipse once the update finishes — you should now see 4.0 as an option when creating a Dynamic Web Project or modifying Project Facets
Option 2: Manually Update Project Configuration Files
If the update doesn’t work for some reason (or you prefer a hands-on approach), you can tweak the project files directly:
- Close your project (or Eclipse entirely) to avoid file conflicts
- Navigate to your project’s root folder, find the hidden
.settingsdirectory - Open
org.eclipse.wst.common.project.facet.core.xmlin a text editor - Locate the line:
<installed facet="jst.web" version="3.1"/> - Change the version to
4.0, so it reads:<installed facet="jst.web" version="4.0"/> - Save the file and reopen your project in Eclipse
- Update your
web.xmlto use the Servlet 4.0 schema (this ensures compatibility):
Replace the existing root element with this code:<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd" version="4.0"> - Verify Tomcat configuration: Go to
Window > Preferences > Server > Runtime Environments, select your Tomcat 9.0.6 instance, clickEdit— you should now see 4.0 available in the "Dynamic web module version" dropdown
Quick Notes
- Tomcat 9.0.x fully supports Servlet 4.0, so your server is already compatible — the issue was purely Eclipse’s missing support
- After making any changes, run a
Project > Clean...to ensure all configurations are properly applied
内容的提问来源于stack exchange,提问作者Vladimir M.
相关产品推荐
相关产品推荐

