java Maven:javaee-api 与 jboss-javaee-6.0
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15518148/
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
Maven: javaee-api vs jboss-javaee-6.0
提问by david24365
I want a Java JEE6 project built with maven, and I want it standard
我想要一个用 maven 构建的 Java JEE6 项目,我想要它的标准
So, I put this in my pom.xml:
所以,我把它放在我的 pom.xml 中:
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>6.0</version>
<scope>provided</scope>
</dependency>
A project like this, it is supposed to run in every JEE6 container compatible (jboss, geronimo, glashfish, etc.)
像这样的项目,它应该在每个兼容 JEE6 的容器(jboss、geronimo、glashfish 等)中运行
Then, why this jboss dependency exists?
那么,为什么会存在这个jboss依赖呢?
<dependency>
<groupId>org.jboss.spec</groupId>
<artifactId>jboss-javaee-6.0</artifactId>
<version>3.0.2.Final</version>
<scope>provided</scope>
</dependency>
If I use it, am I tied to jboss so I can only use this server with this application?
如果我使用它,我是否绑定到 jboss,因此我只能将此服务器与此应用程序一起使用?
Is it not preferable to always use the standard javaee-api?
总是使用标准的 javaee-api 不是更好吗?
Thank you!
谢谢!
回答by omilke
The standard api is crippled, i. e. method bodies are missing. This turns out when testing. I have once run into this pitfall and was not very happy with it.
标准 api 被削弱,即缺少方法体。测试时会出现这种情况。我曾经遇到过这个陷阱,并不太满意。
Therefore it is advisiable to use another package as reference.
因此,建议使用另一个包作为参考。
You can have a closer look on Adam Biens Blog
你可以仔细看看Adam Biens 的博客
You can also make profiles for different deployment environments if you really need. However, essentially I agree, this is sadly not a very pleasant circumstance.
如果您确实需要,您还可以为不同的部署环境制作配置文件。然而,基本上我同意,遗憾的是这不是一个非常愉快的情况。
For having issues with testing, you can have a look at this thread.
对于测试问题,您可以查看此线程。
Edit:
By the way, since now this might be interessting. This issue is gone for the javaee-(web-)api for Java EE 7(source)
编辑:
顺便说一下,因为现在这可能很有趣。Java EE 7的 javaee-(web-)api 没有这个问题(源代码)
回答by Alexander Fedyukov
The first solution with java-api dependence is the right way: your application in ideal case should not be cared about server environment under what it works. For unit test you can use Arquillian, which helps you to test enterprise beans at "home" without headache. If you are using jboss-javaee, are you sure, that your application will deployed and work fine on another server, than jboss?
java-api 依赖的第一个解决方案是正确的方法:在理想情况下,您的应用程序不应该关心它工作的服务器环境。对于单元测试,您可以使用Arquillian,它可以帮助您轻松地“在家”测试企业 bean。如果您正在使用 jboss-javaee,您确定您的应用程序将部署并在另一台服务器上正常工作,而不是 jboss?