如何在Mac OS X中将NetBeans 8与Tomcat 8连接? [英] How to connect NetBeans 8 with Tomcat 8 in Mac OS X?

查看:158
本文介绍了如何在Mac OS X中将NetBeans 8与Tomcat 8连接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现了其他问题和解答,涉及让 NetBeans IDE Apache Tomcat servlet容器.但是它们似乎已经过时或涉及无关紧要的步骤.我记得在Mac上,该过程变得不那么复杂了.但是我不记得确切的步骤.

I found other Questions and Answers dealing with getting the NetBeans IDE to talk to the Apache Tomcat servlet container. But they seem to be out of date or involve extraneous steps. I remember the process as being less complicated on my Mac. But I cannot remember the exact steps.

推荐答案

实际上,让Tomcat与NetBeans进行通信虽然不是很明显,却相当简单.

Indeed, getting Tomcat to talk to NetBeans is fairly simple though not obvious.

如果要下载NetBeans,请获取已经与Tomcat捆绑在一起的NetBeans IDE版本.您可能需要自定义安装以获得Tomcat,如此问题中所述.

If downloading NetBeans, grab an edition of NetBeans IDE already bundled with Tomcat. You may need to customize the installation to get Tomcat, as described in this Question.

但是该版本的Tomcat可能已过时.因此,让我们来看一下使用NetBeans IDE连接Tomcat的新副本.

But that version of Tomcat is likely to be out of date. So let‘s look at hooking up a fresh copy of Tomcat with NetBeans IDE.

首先请确保您的Tomcat副本可以运行.默认情况下,默认情况下,这些权限通常不允许执行,至少以我在Mac上的经验而言.因此,重置权限.如果您是Unix专家,则可以在命令行中进行操作.我们其余的人使用 BatChmod应用.

First be sure your copy of Tomcat can run. The permissions by default usually do not allow execution, at least in my experience on a Mac. So reset the permissions. If you are a Unix whiz, you can do so in the command-line. The rest of us use the BatChmod app.

我打开了除Clear xattrs以外的所有复选框.

I turn on all the checkboxes except Clear xattrs.

通过执行Tomcat bin文件夹中的startup.sh文件来验证Tomcat是否可以运行.将您的Web浏览器指向http://localhost:8080/以查看Tomcat页面.然后运行shutdown.sh退出Tomcat.

Verify that Tomcat can run by executing the startup.sh file in Tomcat’s bin folder. Point your web browser to http://localhost:8080/ to see a Tomcat page. Then run shutdown.sh to quit Tomcat.

提示:您可以删除所有以.bat结尾的文件.这些是仅在Microsoft Windows上使用的批处理"文件. Mac OS X使用以.sh结尾的Unix文件代替.

Tip: You may delete all the files ending in .bat. Those are "batch" files used only on Microsoft Windows. Mac OS X uses the Unix files ending in .sh instead.

Services窗格中,右键单击Servers项.从上下文菜单中,选择Add server.

In the Services pane, context-click on the Servers item. From the context menu, choose Add server.

Big NetBeans提示:如有疑问,请单击上下文. Mac约定是为每个菜单项提供一个主菜单项,而上下文菜单仅是一种方便,而NetBeans则在很大程度上取决于上下文菜单.

Big NetBeans Tip: When in doubt, context-click. While the Mac convention is to provide a main menu item for every item with context-menu being a mere convenience, NetBeans depends heavily on context-menus.

在出现的对话框中,选择Apache Tomcat or TomEE.键入要在服务器"的NetBeans列表中显示的名称.我建议键入"Tomcat"和版本号.

In the dialog that appears, choose Apache Tomcat or TomEE. Type a name to be displayed in NetBeans list of "Servers". I suggest typing "Tomcat" plus the version number.

在该Add Server Instance向导的下一个面板中单击Next.

Click Next for the next panel of this Add Server Instance wizard.

单击Server Location> Browse按钮,然后选择Tomcat文件夹所在的位置.我将我的文件夹保存在"home"文件夹中.

Click the Server Location > Browse button, and choose where your Tomcat folder. I keep mine in my "home" folder.

打开Use Private Configuration Folder复选框.

当您从NetBeans中运行时,我们需要选择一个文件夹供我们Tomcat(特别是Tomcat的Catalina模块)用于工作,保留其临时文件,保留日志以及放置Web应用程序的已安装副本.您必须创建此文件夹.文件夹的位置可以在任何地方.对于其捆绑版本的Tomcat,NetBeans使用嵌套在~/Library/Application Support中的文件夹.但是我倾向于在我的主文件夹中创建一个文件夹,其中包含每个Tomcat版本(例如~/Apache-Tomcat-Netbeans/8.0.27/)的嵌套文件夹. Unix& Java倾向于对文件路径中的空格不理解,因此我在这些文件夹名称中使用连字符而不是空格.

We need to choose a folder where we want Tomcat (specifically, Tomcat’s Catalina module) to do its work, keep its temporary files, keep its logs, and place the installed copy of your web app when you run from within NetBeans. You must create this folder. The folder’s location can be anywhere. For its bundled version of Tomcat, NetBeans uses a folder nested in ~/Library/Application Support. But I tend to create a folder in my home folder with a nested folder for each version of Tomcat, ~/Apache-Tomcat-Netbeans/8.0.27/ for example. Unix & Java tend to get cranky about spaces in file paths, so I use hyphens rather than spaces in those folder names.

单击Cataline Base> Browse按钮以显示文件选择器.使用右上角的Create New Folder图标按钮创建从NetBeans运行时要用于Web应用程序部署的文件夹层次结构(如上段所述).

Click the Cataline Base > Browse button to display a file picker. Use the Create New Folder icon button in the upper right corner to create the folder hierarchy you want to use for your web app’s deployment when run from NetBeans (as discussed in previous paragraph).

最后在该面板中,设置用户名和密码,以用作Tomcat管理器"来启动和关闭Tomcat.确保选中Create user if it does not exist复选框.

Lastly in that panel, make up a user name and password to be used as a Tomcat "manager" to startup and shutdown Tomcat. Be sure to check the Create user if it does not exist checkbox.

向导面板应类似于此屏幕截图.

The wizard panel should look something like this screen shot.

单击Finish按钮.而且,您在NetBeans中定义了一个新的Tomcat服务器.

Click the Finish button. And voilá, you have a new Tomcat server defined within NetBeans.

最后一步是告诉您的项目使用该服务器.

The last step is to tell your project to use that server.

在项目的Properties对话框中,将Build> Run> Server(弹出菜单)设置为新定义的服务器.

In your project’s Properties dialog, set Build > Run > Server (popup menu) to your newly defined server.

这篇关于如何在Mac OS X中将NetBeans 8与Tomcat 8连接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆