使用 Netbeans 在本地 Java 服务器上进行开发

发布于 2024-12-22 03:37:26 字数 1436 浏览 1 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

画尸师 2024-12-29 03:37:26

最简单的服务器是 Jetty ,因为它 100% java 且易于嵌入,没有特定于平台的依赖性。要安装jetty,您只需解压下载的文件。

运行简单的 jetty 教程后,使用 netbeans 创建一个 war 文件 - 然后您只需将 war 拖到 jetty 主目录中的相应文件夹即可轻松在 jetty 中部署 Web 应用程序。

现在 --- 要了解 java Web 服务器的工作原理,您可以阅读 jetty 生成的终端日志,这些日志信息非常丰富** - 您可以观看它解压缩和部署 .war 文件等...并使用任何旧的 Java 分析器来监视其内存/CPU 使用情况。

The simplest server to start with is Jetty , as it's 100% java and embedded easily with no platform specific dependencies. To install jetty, you need only unzip the download.

Once you run a simple jetty tutorial, use netbeans to create a war file - and you can then easily deploy your web application in jetty by just dragging the war to the appropriate folder in jettys home directory.

Now --- To learn about how java web servers work , you can read the terminal logs that jetty produces, which are quite informative** - you can watch as it decompresses and deploys your .war file, etc... And use any old java profilers to monitor its memory/cpu usage.

梦里梦着梦中梦 2024-12-29 03:37:26

NetBeans“运行”命令适用于本地和远程服务器。除了传输时间之外,两者基本上没有区别,只是 NetBeans 无法启动远程服务器——您必须自己启动。

至于使用与 NetBeans“隔离”的服务器,甚至没有理由更改服务器。只需不要从 NetBeans 启动服务器即可。手动启动它并使用您喜欢的任何机制进行部署。 Tomcat 有一个您可以使用的 UI,或者您可以将 Web 应用程序放入 webapps 文件夹中并让它自动部署,Glassfish 您可以使用 UI、asadmin 或 autodeploy 文件夹。

NetBeans 可能实现的唯一其他魔力(尤其是对于 Glassfish)是它可以自动部署连接池等资源。您可以通过启动现有服务器并在部署之前简单地删除这些资源来轻松模仿这一点,然后学习如何手动重新创建它们。

如果您使用 Glassfish,则不必使用现有域,您可以在现有服务器上创建一个全新的域。如果您愿意的话,可以给它不同的端口等等。这很简单,也很容易做到。如果没有端口冲突(和内存),则可以同时启动和关闭两个不同的域。

对于大多数容器来说,部署 WAR 或 EAR 都非常容易。重要的是,您了解可以将项目转移到生产环境的详细信息,但这实际上并不是什么大问题 - 特别是如果您没有大量容器配置要做(共享库、自定义安全领域、连接池等) .)

NetBeans "Run" command works with both local and remote servers. Beyond transfer time, the two are basically indistinguishable, save the NetBeans can not start a remote server -- you have to do that yourself.

As far as working with a server that's "isolated" from NetBeans, there's no reason to even change servers. Simply don't start the server from NetBeans. Start it by hand and use whatever mechanism you like for deployment. Tomcat has a UI you can use, or you can plop the webapp in to the webapps folder and let it auto deploy, Glassfish you can use the UI, or asadmin, or the autodeploy folder.

The only other magic the NetBeans may do, especially for Glassfish, is that it may auto-deploy resources like connection pools and what not. You can easily mimic this by firing up your existing server and simply removing those resources before you deploy, and then learn how to recreate them by hand.

If you're using Glassfish, you don't have to play with your existing domain, you can create a brand new one on your existing server. Give it different ports, if you like, etc. It's straightforward and easy to do. If you have no port conflicts (and the memory), you can bring the two different domains up and down simultaneously.

Deploying a WAR or EAR is pretty easy with most of the containers. It's important you learn the details just do you can move projects to production, but it's really not a big deal -- especially if you don't have a lot of container configuration to do (shared libs, custom security realms, connection pools, etc.)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文