问题
It's actually pretty unlikely for me, but it seems that there is no direct answer over the net about importing JBoss-provided dependencies into Maven-managed Java EE application to be deployed within it.
AFAIK there are 2 things somehow related to the problem, that is jboss-as-client
artifact for external (in sense of JVM) JBoss clients and jboss-as-component-matrix
artifact with huge <dependencyManagement>
block defining version of the libraries that JBoss uses. The latter artifact is pretty useful since I can use Maven's import scope to have all version properly set up. The one that is missing (AFAIK) i something like jboss-as-client
but for deployed Java EE application. Something, that I can depend on with provided
scope and have all stuff in the classpath, including platform-related APIs (like EJB or JMS) and AS-specific stuff (like EJB-ext or jboss-messaging
) and possibly some other stuff from lib
, lib/endorsed
and (mainly) common/lib
directories. I know that probably a better practice (and religion-compatible) would be to be explicit with dependencies used in modules but the way I'm asking about is much more pragmatic for me (sorry), at least for Java EE applications that really use many standard APIs.
I'm really curious about your way of dealing with such challange. I'm using 5.1.0.GA version of the AS.
回答1:
You have to provide your own (infrastructure) maven project which just packages all the mentioned dependencies and all your JBoss projects depend on this infrastructure project with scope provided
.
But shouldn't you compile just against the specification jars instead of the concrete implementation?
Like
<dependency>
<groupId>org.jboss.spec</groupId>
<artifactId>jboss-javaee-6.0</artifactId>
<version>1.0.0.Final</version>
<type>pom</type>
<scope>provided</scope>
</dependency>
Jump to the first occurrence of "Java EE 6 API" on http://arquillian.org/guides/getting_started/.
回答2:
You won't like this answer, but as the libraries are provided at run-time by JBoss, other than using a provided
scope, it is not really your affair. The classes of any unstated transitive dependency will be loaded by a different class loader (presumably), and live nicely together with the application classes.
For the not so nice coupled classes, what @MichalKalinowski said is true.
来源:https://stackoverflow.com/questions/9839689/jboss-provided-libraries-in-maven-managed-java-ee-app