如何在 Eclipse 中使用 Tomcat 8?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17868232/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to use Tomcat 8 in Eclipse?
提问by ECDragon
EDIT 2014-02-07: Eclipse Luna is here, and support for Tomcat 8 is included in the bundled WTP : ) Happy days!
编辑 2014-02-07:Eclipse Luna 在这里,捆绑的 WTP 中包含对 Tomcat 8 的支持:) 快乐的日子!
Tomcat 8 is still in development, but you can get it here. Now there is a RC version on the main Apache Tomcat page. Update 2/27/14: 8 is released now, and adapters built for WTP, just not integrated into eclipse bundles yet. Soon!
Tomcat 8 仍在开发中,但您可以在此处获取。现在主 Apache Tomcat 页面上有一个 RC 版本。2014 年 2 月 27 日更新:8 现已发布,为 WTP 构建的适配器尚未集成到 eclipse 包中。很快!
In Eclipse Kepler though, there is no supported adapter in the add server list for Tomcat 8. the Tomcat 7 adapter doesn't work, and it doesn't look like there's a new extension for it to download in the "Install new Extension" dialog.
但是,在 Eclipse Kepler 中,Tomcat 8 的添加服务器列表中没有受支持的适配器。 Tomcat 7 适配器不起作用,并且看起来在“安装新扩展”中没有可供下载的新扩展对话。
Is my only option to get it (Tomcat 8) running locally outside of Eclipse and maybe hook a remote debugger into it for stepping through code? Will that even work for Eclipse Kepler + Tomcat 8? IntelliJ IDEA 12 couldn't do it in the 30 minutes of time I put into that path.
我唯一的选择是让它(Tomcat 8)在 Eclipse 之外本地运行,并且可能将远程调试器挂接到它以单步调试代码?这甚至适用于 Eclipse Kepler + Tomcat 8 吗?IntelliJ IDEA 12 无法在我投入该路径的 30 分钟内完成。
If you're wondering why I'm trying to do this at all, I'm playing around with Spring 4.0.0.M1 and 4.0.0.M2 WebSocket stuff. They (per Rossen Stoyanchev's Spring 4.0 blog postand examples) use JSR-356, which is implemented in Tomcat 8, theoretically to be back-ported at some point to Tomcat 7.
如果你想知道我为什么要这样做,我正在玩 Spring 4.0.0.M1 和 4.0.0.M2 WebSocket 的东西。他们(根据 Rossen Stoyanchev 的 Spring 4.0博客文章和示例)使用 JSR-356,它在 Tomcat 8 中实现,理论上会在某个时候向后移植到 Tomcat 7。
An answer to the broader question of "How can I easily get a development environment going for Spring 4 WebSocket support?" would be nice, but it would also still be nice to know how to plug in unsupported web servers to Eclipse.
回答更广泛的问题“如何轻松获得支持 Spring 4 WebSocket 的开发环境?” 会很好,但知道如何将不受支持的 Web 服务器插入 Eclipse 也很好。
Cheers, E
干杯,E
**Update 8/7/13 - Rossen Stoyanchev updated the Spring 4.0.0.M2 blogand added some jpda wisdom and shared that yeah, he's using remote debugging:
** 2013 年 8 月 7 日更新 - Rossen Stoyanchev 更新了 Spring 4.0.0.M2 博客并添加了一些 jpda 智慧并分享了是的,他正在使用远程调试:
That said, it's not very hard to debug with Tomcat 8 inside Eclipse. Just change the last line in bin/startup.sh to be (note the addition of "jpda"):
exec "$PRGDIR"/"$EXECUTABLE" jpda start "$@"
Inside Eclipse create a remote debugging configuration for localhost port 80, launch it after starting Tomcat, and you can put breakpoints in the source code.
也就是说,在 Eclipse 中使用 Tomcat 8 进行调试并不难。只需将 bin/startup.sh 中的最后一行更改为(注意添加了“jpda”):
exec "$PRGDIR"/"$EXECUTABLE" jpda start "$@"
在Eclipse里面创建localhost 80端口的远程调试配置,启动Tomcat后启动,可以在源码中设置断点。
Thanks Rossen!
谢谢罗森!
**Update 9/29/13 - Eclipse Kepler SR1 just arrived, but alas! No WTP support for Tomcat 8. Tomcat 8 is up to RC3.
** 2013 年 9 月 29 日更新 - Eclipse Kepler SR1 刚刚到货,但唉!Tomcat 8 不支持 WTP。Tomcat 8 最高可达 RC3。
**Updates 12/5/13
**更新 12/5/13
- Blog url fix.
- Tomcat 8 up to RC5.
- Bug to track WTP fix in Eclipse to support Tomcat 8 HERE.
- IntelliJ IDEA new version 13 says it now supports Tomcat 8. Haven't tried yet personally.
- 博客网址修复。
- Tomcat 8 到 RC5。
- 错误跟踪在Eclipse WTP修复支持Tomcat的8 HERE。
- IntelliJ IDEA新版本13说现在支持Tomcat 8了,个人还没试过。
回答by Jason
UPDATE: Eclipse Mars EE and later have native support for Tomcat8. Use this only if you have an earlier version of eclipse.
更新:Eclipse Mars EE 及更高版本对 Tomcat8 提供本机支持。仅当您有较早版本的 eclipse 时才使用此选项。
The latest version of Eclipse still does not support Tomcat 8, but you can add the new version of WTP and Tomcat 8 support will be added natively. To do this:
最新版本的 Eclipse 仍然不支持 Tomcat 8,但是您可以添加新版本的 WTP,并且会在本机添加 Tomcat 8 支持。去做这个:
- Download the latest version of Eclipse for Java EE
- Go to the WTP downloads page, select the latest version (currently 3.6), and download the zip (under Traditional Zip Files...Web App Developers). Here's the current link.
- Copy the all of the files in features and plugins directories of the downloaded WTP into the corresponding Eclipse directories in your Eclipse folder (overwriting the existing files).
- 下载最新版本的Java EEEclipse
- 转到WTP 下载页面,选择最新版本(当前为 3.6),然后下载 zip(在传统 Zip 文件...Web App Developers 下)。这是当前链接。
- 将下载的 WTP 的 features 和 plugins 目录中的所有文件复制到 Eclipse 文件夹中相应的 Eclipse 目录中(覆盖现有文件)。
Start Eclipse and you should have a Tomcat 8 option available when you go to deploy.
启动 Eclipse,在部署时应该有一个 Tomcat 8 选项可用。
回答by wener
I follow Jason's step, but not works.
我遵循杰森的步骤,但不起作用。
And then I find the WTP Update site http://download.eclipse.org/webtools/updates/.
然后我找到了 WTP 更新站点http://download.eclipse.org/webtools/updates/。
Help -> Install new software -> Add > WTP:http://download.eclipse.org/webtools/updates/ -> OK
Help -> Install new software -> Add > WTP:http://download.eclipse.org/webtools/updates/ -> OK
Then Help -> Check for update
, just works, I don't know whether Jason's affect this .
然后Help -> Check for update
,就行了,不知道杰森的有没有影响。
回答by Javier Sabino
The only thing the eclipse plugin is checking is the tomcat version inside:
eclipse 插件唯一检查的是里面的 tomcat 版本:
catalina.jar!/org/apache/catalina/util/ServerInfo.properties
I replaced the properties file with the one in tomcat7 and that fixed the issue for eclipse
我用 tomcat7 中的属性文件替换了属性文件,并解决了 eclipse 的问题
In order to be able to deploy the spring-websockets sample app you need to edit the following file in eclipse:
为了能够部署 spring-websockets 示例应用程序,您需要在 Eclipse 中编辑以下文件:
.settings/org.eclipse.wst.common.project.facet.core.xml
And change the web version to 2.5
并将网页版更改为 2.5
<installed facet="jst.web" version="2.5"/>
回答by Wildly Stunted
This should be a comment under the accepted answer, but I don't have 50 reputation yet.
这应该是已接受答案下的评论,但我还没有 50 声望。
At http://download.eclipse.org/webtools/downloads/
在http://download.eclipse.org/webtools/downloads/
I first selected Released 3.5.2, which like others did not work for me. Then I picked Integration 3.6.0, and saw Tomcat 8 for New Project of Dynamic Web Project.
我首先选择了 Released 3.5.2,它像其他人一样不适合我。然后我选择了Integration 3.6.0,看到了Tomcat 8 for New Project of Dynamic Web Project。
回答by manali
I have tried below and it worked for me.
我在下面尝试过,它对我有用。
- In eclipse go to Help->Eclipse Marketplace
- Type JST extension in search box.
- Install JSP Adapters for Luna
- Restart the eclispe
- You should be able to see Tocmat 8 server while adding new server.
- 在 Eclipse 中转到 Help->Eclipse Marketplace
- 在搜索框中键入 JST 扩展名。
- 为 Luna 安装 JSP 适配器
- 重启 eclispe
- 添加新服务器时,您应该能够看到 Tocmat 8 服务器。
回答by lko
In addition to @Jason's answer I had to do a bit more to get my app to run.
除了@Jason 的回答之外,我还需要做更多的工作才能让我的应用程序运行。
- Download & unzip Eclipse IDE for Java EE Developers(Note the EEedition)
- Download & unzip Eclipse's Web Tools PlatformStable (Milestone) 3.6+
- Overwrite the two folders in the Eclipse IDE, with the WTP folder(s) (features & plugins folders)
- Download and unzip Tomcat 8
- In eclipse new -> other -> server -> Tomcat 8 (choose the unzipped location)
- If you get a 404, click the Tomcat 8 in the Servers view -> Server Locations-> Change to Use Tomcat installation, and change the Deploy path: to webapps* (If you can't edit this, delete any published webapps)
- 为 Java EE 开发人员下载并解压Eclipse IDE(注意EE版本)
- 下载并解压 Eclipse 的Web Tools PlatformStable (Milestone) 3.6+
- 用 WTP 文件夹(功能和插件文件夹)覆盖 Eclipse IDE 中的两个文件夹
- 下载并解压Tomcat 8
- 在eclipse new -> other -> server -> Tomcat 8(选择解压位置)
- 如果得到 404,请在 Servers view -> Server Locations-> Change to Use Tomcat installation 中单击 Tomcat 8 ,然后将Deploy path: to webapps* (如果无法编辑,请删除任何已发布的 webapps)
回答by Jeewantha Samaraweera
To add the Tomcat 9.0 (Tomcat build from the trunk) as a server in Eclipse.
在 Eclipse 中添加 Tomcat 9.0(Tomcat 从主干构建)作为服务器。
Update the ServerInfo.properties file properties as below.
更新 ServerInfo.properties 文件属性,如下所示。
server.info=Apache Tomcat/@VERSION@
server.number=@VERSION_NUMBER@
server.built=@VERSION_BUILT@
server.info=Apache Tomcat/7.0.57
server.number=7.0.57.0
server.built=Nov 3 2014 08:39:16 UTC
Build the tomcat server from trunk and add the server as tomcat7 instance in Eclipse.
从trunk 构建tomcat 服务器,并在Eclipse 中将服务器添加为tomcat7 实例。
ServerInfo.properties file location : \tomcat\java\org\apache\catalina\util\ServerInfo.properties
ServerInfo.properties 文件位置:\tomcat\java\org\apache\catalina\util\ServerInfo.properties
回答by Kishore Guruswamy
Downloaded Eclipse Luna and installed WTP using http://download.eclipse.org/webtools/repository/luna
下载 Eclipse Luna 并使用http://download.eclipse.org/webtools/repository/luna安装 WTP
Downloaded Tomcat 8 and configured new server in Eclipse. I am able to setup tomcat 8 now in Eclipse luna
下载 Tomcat 8 并在 Eclipse 中配置新服务器。我现在可以在 Eclipse luna 中设置 tomcat 8
回答by Callum Wilson
If you have untarred your own version of tomcat v8 with a rootuser into a custom directory (linux) then the default permissions on the TOMCATROOT/lib directory do not allow normal user access.
如果您使用root用户将自己的 tomcat v8 版本解压到自定义目录 (linux) 中,则 TOMCATROOT/lib 目录的默认权限不允许普通用户访问。
Eclipse will not be able to see the catalina.jar to check the version. So no amount of fiddling aorund with the server.properties will help!
Eclipse 将无法查看 catalina.jar 以检查版本。因此,再多摆弄 server.properties 都无济于事!
just add chmod u+x lib/ to allow normal user access to the libs.
只需添加 chmod u+x lib/ 以允许普通用户访问库。
回答by TechTrip
The latest version of Springsource STS (3.6) supports Tomcat 8. It is based on eclipse Luna 4.4 and supports Java 8. Have at it!
Springsource STS (3.6) 最新版本支持Tomcat 8,基于eclipse Luna 4.4,支持Java 8。快来试试吧!