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

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

问题描述

我发现了其他关于让

但是那个版本的Tomcat很可能已经过时了.因此,让我们看看如何将 Tomcat 的新副本与 NetBeans IDE 连接起来.

文件权限

首先确保您的 Tomcat 副本可以运行.默认情况下,权限通常不允许执行,至少根据我在 Mac 上的经验.所以重置权限.如果您是 Unix 高手,则可以在命令行中执行此操作.我们其他人使用

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

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

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

在 NetBeans 中定义服务器

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

Big NetBeans 提示:如有疑问,请单击上下文.虽然 Mac 惯例是为每个项目提供一个主菜单项,而上下文菜单只是为了方便,但 NetBeans 严重依赖于上下文菜单.

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

点击 Next 进入这个 Add Server Instance 向导的下一个面板.

Tomcat 位置

单击Server Location > Browse 按钮,然后选择Tomcat 文件夹的位置.我把我的放在我的家"文件夹中.

部署地点

打开使用私有配置文件夹复选框.

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

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

Tomcat 管理员用户

最后在该面板中,创建用户名和密码以用作 Tomcat管理器"来启动和关闭 Tomcat.请务必选中如果不存在则创建用户复选框.

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

点击完成按钮.瞧,您已经在 NetBeans 中定义了一个新的 Tomcat 服务器.

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

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

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.

解决方案

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

Java EE edition of NetBeans

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.

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.

File Permissions

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.

I turn on all the checkboxes except Clear xattrs.

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.

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.

Define a Server in NetBeans

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

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.

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.

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

Tomcat Location

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

Deployment Location

Turn on the Use Private Configuration Folder checkbox.

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.

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 Manager User

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.

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.

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天全站免登陆