简体   繁体   English

在Ubuntu上的Eclipse中设置Tomcat

[英]Setting up Tomcat in Eclipse on Ubuntu

I'm trying to setup Tomcat in Eclipse. 我正在尝试在Eclipse中设置Tomcat。 I've already followed this tutorial on how to install Tomcat and I'm even able to see the default Tomcat page at localhost:8080 . 我已经按照本教程了解如何安装Tomcat ,甚至可以在localhost:8080看到默认的Tomcat页面。

What I need now is to setup Tomcat on Eclipse. 现在,我需要在Eclipse上设置Tomcat。

I do the following: 我执行以下操作:

Window->Preferences->Server->Runtime Environment->Add->"Apache Tomcat v8.5"

As Tomcat's installation directory I enter /opt/tomcat , as specified in the tutorial linked above in Step 3: Install Tomcat : 作为Tomcat的安装目录,我输入/opt/tomcat ,如上面在Step 3: Install Tomcat链接的教程中所指定:

We will install Tomcat to the /opt/tomcat directory. 我们将Tomcat安装到/ opt / tomcat目录。 Create the directory, then extract the archive to it [...] 创建目录,然后将存档解压缩到其中[...]

But I get the following error: 但是我收到以下错误:

Unknown version of Tomcat was specified. 指定了未知版本的Tomcat。

As can be seen here: 如此处所示:

在此处输入图片说明

Some more infos: 更多信息:

  • Tomcat 8.5.20 的Tomcat 8.5.20
  • Eclipse Java EE IDE for Web Developers (4.7.0) 针对Web开发人员的Eclipse Java EE IDE(4.7.0)
  • Ubuntu 17.04 Ubuntu 17.04

Update: 更新:

When I check the permission with ls -ltra /opt/tomcat I get that output: 当我使用ls -ltra /opt/tomcat检查权限时,得到以下输出:

total 124
drwxr-x---  7 tomcat tomcat  4096 Aug  2 23:36 webapps
-rw-r-----  1 tomcat tomcat 15946 Aug  2 23:36 RUNNING.txt
-rw-r-----  1 tomcat tomcat  7064 Aug  2 23:36 RELEASE-NOTES
-rw-r-----  1 tomcat tomcat  1723 Aug  2 23:36 NOTICE
-rw-r-----  1 tomcat tomcat 57092 Aug  2 23:36 LICENSE
drwxr-xr-x  6 root   root    4096 Aug 11 17:56 ..
drwxr-x---  2 tomcat tomcat  4096 Aug 11 17:56 lib
drwxr-x---  2 tomcat tomcat  4096 Aug 11 17:56 bin
drwxr-x---  2 tomcat tomcat  4096 Aug 12 14:53 .oracle_jre_usage
drwxr-xr-x 10 tomcat tomcat  4096 Aug 12 14:53 .
drwxr-x---  3 tomcat tomcat  4096 Aug 12 14:53 work
drwxr-x---  3 tomcat tomcat  4096 Aug 12 15:01 conf
drwxr-x---  2 tomcat tomcat  4096 Aug 14 17:21 temp
drwxr-x---  2 tomcat tomcat  4096 Aug 14 17:21 logs

You really don't want Eclipse and a production installation of Tomcat to mix. 您确实不希望Eclipse和Tomcat的生产安装混合使用。 The most straightforward thing to do is to download a tarball from http://tomcat.apache.org/ , unpack it, and point the Server -> Runtime Environments preference page at that. 最简单的事情是从下载一个压缩文件http://tomcat.apache.org/ ,解压缩,并指出服务器 -在那个> 运行时环境首选项页。 This lets you sidestep any file permission issues as long as your make sure that they don't try to use the same ports. 只要您确保它们不尝试使用相同的端口,就可以避开任何文件许可问题。

您只需要授予权限

chmod -R 777 /opt/tomcat/

Open the Servers view and add the Tomcat server: 打开“服务器”视图并添加Tomcat服务器:

Window > Show View > Servers

In the Server view right click and select 在“服务器”视图中,右键单击并选择

New > Server

Now you'll get a window that looks like the one below. 现在,您将获得一个类似于以下窗口的窗口。 Open the Apache tab and scroll down to Tomcat 8.5 click on it and then click Next. 打开Apache选项卡,然后向下滚动到Tomcat 8.5,单击它,然后单击Next。

在Eclipse中添加新服务器

In the next window you will be asked to select resources that are configured on the server. 在下一个窗口中,将要求您选择服务器上配置的资源。 If you don't see any it means you will need to go to your project and add Dynamic Web Module facet. 如果没有看到任何内容,则意味着您需要转到项目并添加Dynamic Web Module构面。 This can be done as follows: 可以按照以下步骤进行:

Properties > Project Facets

为项目添加构面

At this point you should be able to start the server and run your project using the controls in the top right of the Servers view, or by right clicking on the specific server. 此时,您应该能够使用“服务器”视图右上角的控件或右键单击特定服务器来启动服务器并运行项目。 You can add several installations of Jetty, Tomcat, Resin, JBoss, etc if you need them by the way. 如果需要,您可以添加Jetty,Tomcat,Resin,JBoss等的多个安装。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM