在 Mac 上设置 IntelliJ 和 GlassFish

发布于 2024-10-04 20:20:29 字数 326 浏览 1 评论 0原文

我正在寻求帮助,以制定使用 IntelliJ 和 GlassFish 在 Mac 上启动并运行基本“hello world”Web 应用程序所需的步骤。到目前为止,我已经找到本指南,这很有帮助,但已经过时了(一些对话框/步骤自编写以来已经发生了变化)。

精通这些工具的任何人都可以帮助我整理使用 IntelliJ 9.0.4 将基本 Web 应用程序部署到 GlassFish 3.0.1 所需的步骤吗?

I'm looking for help coming up with the steps required to get a basic "hello world" web app up and running on a Mac using IntelliJ and GlassFish. So far I've found this guide, which is helpful but outdated (some dialogs/steps have changed since it was written).

Can anyone well-versed in these tools help me sort out the steps required to get a basic web app deployed to GlassFish 3.0.1 using IntelliJ 9.0.4?

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

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

发布评论

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

评论(4

离去的眼神 2024-10-11 20:20:29

首先,让 Glassfish 独立运行。这种体验会对您很有帮助,因为该过程在所有 Unix 系统上几乎都是相同的。如果您只学习通过 IDE 与 Glassfish 交互,那么如果没有 IDE,您将完全迷失方向。

部署应用程序有两种方法:通过管理 Web 界面(用户友好,但速度慢得令人痛苦),或通过命令行。执行后者的方法如下:首先,确保 Glassfish 附带的 asadmin 实用程序在您的路径上,然后执行如下操作:

asadmin --user admin deploy --name hello ~/projects/hello/build/hello.ear

默认情况下,admin 用户的密码为空;如果没有,系统会提示您输入。

First, get Glassfish running on its own. This experience will serve you well, since the process is pretty much the same on all Unix systems. If you only learn to interact with Glassfish through your IDE, then you'll be totally lost without the IDE.

There are two ways to deploy an app: through the admin web interface (user-friendly, but painfully slow), or through the command line. Here's how you do the latter: first, make sure that the asadmin utility that came with Glassfish is on your path, then do something like this:

asadmin --user admin deploy --name hello ~/projects/hello/build/hello.ear

By default, the admin user has an empty password; if it doesn't, you'll be prompted for it.

半透明的墙 2024-10-11 20:20:29

我不了解 Glassfish,但我可以告诉你如何使用 Tomcat 做到这一点。唯一的区别应该是您在 IntelliJ 中启动的应用程序服务器:

  1. 在项目设置下,创建一个 Web 模块 - 这将为您提供 /WEB-INF 和 web.xml
  2. 在项目设置下,创建一个映射到分解的 WAR 的工件文件。确保您需要的 JAR 已添加到 WEB-INF/lib 中;您的 .class 文件被复制到 WEB-INF/classes;所有必要的资源都放在您想要的地方。
  3. 设置 Glassfish 并告诉它部署分解的 WAR 工件。将您的 Web 应用程序的名称指定为上下文根(例如“/foo”)。
  4. 运行网络应用程序。 IntelliJ 将编译您的代码,在 /out 目录中创建分解的 WAR 工件,然后部署到您的应用程序服务器。
  5. 您应该看到应用程序在 URL http://localhost:4848/foo/index.html,假设您的 web.xml

JNDI 设置中有一个 index.html 欢迎文件是另一回事。

I don't know about Glassfish, but I can tell you how to do it with Tomcat. The only difference should be the app server that you start inside IntelliJ:

  1. Under project settings, create a web module - that'll give you your /WEB-INF and web.xml
  2. Under project settings, create an artifact that maps to your exploded WAR file. Make sure that the JARs you need are added to the WEB-INF/lib; your .class files are copied to WEB-INF/classes; all necessary resources are put where you want them.
  3. Set up Glassfish and tell it to deploy your exploded WAR artifact. Give it the name of your web app as context root (e.g., "/foo").
  4. Run the web app. IntelliJ will compile your code, create the exploded WAR artifact in the /out directory, and deploy to your app server.
  5. You should see the app start under the URL http://localhost:4848/foo/index.html, assuming you have an index.html welcome file in your web.xml

JNDI set up is another matter.

恍梦境° 2024-10-11 20:20:29

IMO 在任何应用程序服务器上部署 EAR/WAR 的最佳方法是使用 Maven 构建 EAR 和 Cargo Maven 插件以进行重新部署。我使用它的原因是它完全独立于 IDE,并且可以在开发和我的持续集成服务器中使用它。

Glassfish 的 EAR/WAR 模块的 pom.xml 片段:

<plugin>
    <groupId>org.codehaus.cargo</groupId>
    <artifactId>cargo-maven2-plugin</artifactId>
    <version>1.0.2</version>
    <configuration>
        <container>
            <containerId>glassfish2x</containerId> <!-- or glassfish3x -->
            <type>installed</type>
            <home>${glassfish.home}</home>
        </container>
        <configuration>
            <properties>
                <cargo.remote.password>${glassfish.password}</cargo.remote.password>
            </properties>
        </configuration>
        <deployer>
            <type>installed</type>
            <deployables>
                <deployable>
                    <location>${project.build.directory}/${project.build.finalName}.${project.packaging}</location>
                </deployable>
            </deployables>
        </deployer>
    </configuration>
</plugin>

重新部署命令:

mvn cargo:redeploy -Dglassfish.home=/path/to/glassfish/-Dglassfish.password=adminadmin -DskipTests=true -o

如果您不知道 Maven 2 是什么,您应该了解它。

IMO the best way to have an EAR/WAR deployed on any application server is to use Maven to build an EAR and Cargo Maven plugin for redeploying. The reason why I would use it is that it's totally IDE-independent and can use it both in development and my continuous integration server.

pom.xml fragment of EAR/WAR module for Glassfish:

<plugin>
    <groupId>org.codehaus.cargo</groupId>
    <artifactId>cargo-maven2-plugin</artifactId>
    <version>1.0.2</version>
    <configuration>
        <container>
            <containerId>glassfish2x</containerId> <!-- or glassfish3x -->
            <type>installed</type>
            <home>${glassfish.home}</home>
        </container>
        <configuration>
            <properties>
                <cargo.remote.password>${glassfish.password}</cargo.remote.password>
            </properties>
        </configuration>
        <deployer>
            <type>installed</type>
            <deployables>
                <deployable>
                    <location>${project.build.directory}/${project.build.finalName}.${project.packaging}</location>
                </deployable>
            </deployables>
        </deployer>
    </configuration>
</plugin>

Redeploy command:

mvn cargo:redeploy -Dglassfish.home=/path/to/glassfish/-Dglassfish.password=adminadmin -DskipTests=true -o

You should learn about Maven 2 if you don't know what it is.

转身泪倾城 2024-10-11 20:20:29

我成功完成了本教程:在 IntelliJ IDEA 10 中开发 GlassFish Server 应用程序。我正在使用 IDEA 11 和 GlassFish 3.1.2

I had success with this tutorial: Developing applications for GlassFish Server in IntelliJ IDEA 10. I'm using IDEA 11 and GlassFish 3.1.2

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