问题描述
我在Windows 8上使用Eclipse Oxygen.2(4.7.2)和Java 8.我有一个使用Tomcat在Eclipse内部运行的分面项目。我一直在使用Tomcat 8.5,但在新系统上我升级到Tomcat 9.当然,我在Eclipse中删除了Tomcat 8.5服务器和服务器运行时,并添加了Tomcat 9服务器运行时。
在Eclipse中添加Tomcat 9服务器之前,我验证了项目的Project Facets。我看到动态Web模块设置为3.1,但现在4.0可用。我改为4.0,认为这可以让我访问更新的API。
然后我尝试添加Tomcat 9服务器。在此过程中,在添加和删除时,它会询问我要为服务器配置要添加的项目。我选择了我的Web项目,但Eclipse说:Tomcat 9.0版仅支持J2EE 1.2,1.3,1.4和Java EE 5,6,7和8 Web模块。
据我所知,这正是我正在使用的。但我唯一改变的是动态网络模块。所以我回到我的项目配置,并尝试将动态Web模块更改回3.1。 Eclipse告诉我:
嗯...所以我只是删除它。我取消选中Dynamic Web Module旁边的框,Eclipse告诉我:
那是一个很好的鱼。我无法将项目部署到Tomcat,显然是因为动态Web模块。我无法将动态Web模块更改回原来的状态。我该怎么办?问题出在哪里?
我打开了
(这有点像黑客但它有效):
- 在项目的 .settings 目录中编辑 org.eclipse.wst.common.project.facet.core.xml 文件。
- 对于包含 facet =jst.webversion =4.0的行,请将版本更改为 3.1 。
另见SO问题:
一些相关问题:
-
看起来其他东西可能不太适合您的设置获得该错误Tomcat 9.0版仅支持J2EE 1.2,1.3, 1.4和Java EE 5,6,7和8 Web模块。您的项目是否配置为使用Servlet 4.0?对于我的Maven项目,我必须 for Servlet 4。
-
即使将动态Web模块版本更改为3.1,我的Web应用程序继续使用4.0版,所以我不确定是什么facet实现。
I'm using Eclipse Oxygen.2 (4.7.2) on Windows 10 with Java 8. I have a faceted project I run inside Eclipse using Tomcat. I had been using Tomcat 8.5, but on a new system I upgraded to Tomcat 9. Of course I removed the Tomcat 8.5 server and server runtime within Eclipse, and added back a Tomcat 9 server runtime.
Before adding the Tomcat 9 server within Eclipse I verified the Project Facets of my project. I saw that Dynamic Web Module was set to "3.1", but that now "4.0" was available. I changed to "4.0", figuring this would give me access to newer APIs.
I then tried to add the Tomcat 9 server. During the process, at "Add and Remove" it asks me which projects I want to add to be configured for the server. I selected my web project, but Eclipse said: "Tomcat version 9.0 only supports J2EE 1.2, 1.3, 1.4, and Java EE 5, 6, 7, and 8 Web modules".
Now as far as I know that's exactly what I'm using. But the only thing I had changed was the Dynamic Web Module. So I went back to my project configuration and tried to change "Dynamic Web Module" back to "3.1". Eclipse tells me:
Um… so I'll just remove it. I unchecked the box next to "Dynamic Web Module", and Eclipse tells me:
Well that's a fine kettle of fish. I can't deploy my project to Tomcat, apparently because of the Dynamic Web Module. I can't change the Dynamic Web Module back to what it was. What do I do? Where does the problem lie?
I opened Eclipse Bug 530844 to see if I can get some reasons for this behavior.
I reproduced the problem in the same environment as yours. When I tried to regress from 4.0 back to 3.1 I got the following error:
This blog provided the solution (which is a bit of a hack but it works):
- Edit the file org.eclipse.wst.common.project.facet.core.xml in the project's .settings directory.
- For the line containing facet="jst.web" version="4.0", change the version to 3.1.
Also see this SO question: Dynamic Web Module 3.0 -- 3.1
A couple of related issues:
It looks like something else may not be quite right with your setup to be getting that error "Tomcat version 9.0 only supports J2EE 1.2, 1.3, 1.4, and Java EE 5, 6, 7, and 8 Web modules". Is your project configured to use Servlet 4.0? For my Maven project I had to add this dependency to the POM for Servlet 4.
Even after changing the Dynamic Web Module version to 3.1 my web app continued using version 4.0, so I'm not sure what that facet achieves.
这篇关于Eclipse不可逆动态Web模块4.0选择; Tomcat 9不支持它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!