java 要使用哪个 Maven GlassFish 插件?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1836317/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Which Maven GlassFish plugin to use?
提问by Nick Klauer
I've been trying to integrate deploying java .war's in GlassFish V3 through Maven. While I have found a few plugins, none of them look to be very active:
我一直在尝试.war通过 Maven 在 GlassFish V3 中集成部署 java 。虽然我找到了一些插件,但它们看起来都不是很活跃:
And I got the most information out of Eskato's Blog, it was written March 2008, so I don't know what the state of GlassFish Maven integration is, nor can I find a suitable plugin to work with. With the Maven GlassFish PluginI have had some success, but it still doesn't work entirely well for all goals it says it supports, which makes some of the commands ineffective.
我从Eskato 的博客中获得了最多的信息,它写于 2008 年 3 月,所以我不知道 GlassFish Maven 集成的状态,也找不到合适的插件来使用。使用Maven GlassFish 插件我已经取得了一些成功,但它仍然不能完全适用于它所说的支持的所有目标,这使得某些命令无效。
Has anyone else been able to integrate Glassfish V3 and Maven successfully? If so, what resources did you use to get it done?
有没有其他人能够成功地集成 Glassfish V3 和 Maven?如果是这样,您使用了哪些资源来完成它?
回答by Pascal Thivent
Update:CARGO-491has been fixed and I've updated my answer accordingly. To summarize, there are now basically three options:
更新:CARGO-491已修复,我已相应更新我的答案。总结一下,现在基本上有三种选择:
Maven GlassFish Plugin
Maven GlassFish 插件
A first option would be to use the Maven GlassFish Plugin. This plugin allows to interact with a local or remote GlassFish install and the management of Glassfish domains and component deployments from within the Maven build lifecycle.
第一个选择是使用Maven GlassFish 插件。这个插件允许在 Maven 构建生命周期内与本地或远程 GlassFish 安装以及Glassfish 域和组件部署的管理进行交互。
Maven Embedded GlassFish Plugin
Maven 嵌入式 GlassFish 插件
The second option would be to use the Maven Embedded Glassfish Plugin. As stated by its name, this plugin doesn't rely on an existing install but uses an embedded GlassFish, running in the same JVM as the plugin. This plugin is extremely nice if you want to keep your build portable (anybody can get your POM and run a build involving GlassFish without having it installed) with almost the same features as a normal GlassFish install, except clustering of course (you can use a preconfigured domain.xmlif you want). See Testing with the GlassFish Maven plugin and JavaDB Embeddedfor an example.
第二种选择是使用Maven Embedded Glassfish Plugin。顾名思义,该插件不依赖于现有安装,而是使用嵌入式 GlassFish,与插件在同一 JVM 中运行。如果您想保持构建的可移植性(任何人都可以获取您的 POM 并运行涉及 GlassFish 的构建而无需安装它),该插件非常好,它具有与普通 GlassFish 安装几乎相同的功能,当然除了集群(您可以使用domain.xml如果需要,可以预先配置)。有关示例,请参阅使用 GlassFish Maven 插件和 JavaDB Embedded进行测试。
Maven Cargo Plugin
Maven 货物插件
The work initiated by Kohsuke Kawagushi as been finally integrated in Cargo and, starting with Cargo 1.0.1, GlassFish 3.x is now supported. Using the Maven Cargo pluginis thus a third option. This would be interesting for builds that want to interact with containers in an agnostic way. But I'm not sure Cargo allows all the flexibility of the GlassFish specific plugin(s) (e.g. deployment of JMS resources, etc).
由Kohsuke Kawagushi作为发起最后被集成在货运和,从货物1.0.1的工作,现在支持的GlassFish 3.x的。因此,使用Maven Cargo 插件是第三种选择。这对于想要以不可知的方式与容器交互的构建来说会很有趣。但我不确定 Cargo 是否允许 GlassFish 特定插件的所有灵活性(例如部署 JMS 资源等)。
回答by Harald Wellmann
maven-glassfish-plugin and maven-embedded-glassfish-plugin both have their pros and cons. The main difference is that the latter works with an Embedded Glassfish instance, as indicated by its name, i.e. the server is running in the same VM as the plugin.
maven-glassfish-plugin 和 maven-embedded-glassfish-plugin 各有优缺点。主要区别在于后者使用嵌入式 Glassfish 实例,如其名称所示,即服务器与插件在同一 VM 中运行。
So you cannot use maven-embedded-glassfish-plugin to deploy your WAR to a standalone Glassfish server, you need maven-glassfish-plugin to do that.
所以你不能使用 maven-embedded-glassfish-plugin 将你的 WAR 部署到一个独立的 Glassfish 服务器,你需要 maven-glassfish-plugin 来做到这一点。
The main problem I had with the maven-glassfish-plugin is the fact that its interaction with the Glassfish server is stateful - I could not find a way to use it such that my WAR would get deployed to the server in any case, no matter whether the previous build succeeded or not.
我对 maven-glassfish-plugin 的主要问题是它与 Glassfish 服务器的交互是有状态的——我找不到一种使用它的方法,这样我的 WAR 无论如何都会被部署到服务器上,无论如何之前的构建是否成功。
glassfish:deploy does not work if the WAR is deployed already. glassfish:redeploy does not work if the WAR is not deployed. And Maven has no if-else logic...
如果 WAR 已经部署, glassfish:deploy 将不起作用。如果未部署 WAR, glassfish:redeploy 将不起作用。Maven 没有 if-else 逻辑......
回答by Bruno Borges
I've blogged about how to configure Maven Embedded GlassFish plugin to work correctly with GlassFish 4.0 until there's a new release of that plugin.
我已经在博客中介绍了如何配置 Maven 嵌入式 GlassFish 插件以与 GlassFish 4.0 一起正常工作,直到该插件发布新版本。
https://blogs.oracle.com/brunoborges/entry/glassfish_4_beta_and_maven
https://blogs.oracle.com/brunoborges/entry/glassfish_4_beta_and_maven
Also, it is possible to configure a datasource in the glassfish-resources.xml and have it working correctly.
此外,可以在 glassfish-resources.xml 中配置数据源并使其正常工作。
https://blogs.oracle.com/brunoborges/entry/configure_datasources_for_maven_embedded
https://blogs.oracle.com/brunoborges/entry/configure_datasources_for_maven_embedded
These are useful tips to anyone that want to run Java EE 7 projects with Maven and GlassFish 4
对于想要使用 Maven 和 GlassFish 4 运行 Java EE 7 项目的任何人来说,这些都是有用的提示
回答by incomplete
You can use this one :
你可以使用这个:
http://www.hascode.com/2011/09/java-ee-6-development-using-the-maven-embedded-glassfish-plugin/
http://www.hascode.com/2011/09/java-ee-6-development-using-the-maven-embedded-glassfish-plugin/
https://github.com/andrzejsliwa/glassfish-maven-plugin/wiki
https://github.com/andrzejsliwa/glassfish-maven-plugin/wiki
回答by incomplete
I use the glassfish plugin on maven-glassfish-plugin.dev.java.net and did some code changes to support v3 now. I requested committer status and wait for acknowledgement. Hopefully I can commit my changes.
我在 maven-glassfish-plugin.dev.java.net 上使用 glassfish 插件,并做了一些代码更改以现在支持 v3。我请求提交者状态并等待确认。希望我可以提交我的更改。

