Reputation: 31252
In our project, we have separate modules for REST layer, EJB layer and domain (Entity) layer.
Here is the dependency on our REST layer:
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jaxrs</artifactId>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jettison-provider</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-multipart-provider</artifactId>
</dependency>
<!-- Resteasy Server Cache -->
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-cache-core</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jackson-provider</artifactId>
</dependency>
Q1: Is there a single dependency of org.jboss.resteasy
that provides all of these? Any possibility for simplification? should all these dependencies be explicitly declared? If not, what does RestEasy provides some by default? In fact, I use JBoss AS 6. so these dependencies are only for compile time. Their scope is provided
anyway.
Same holds for our Domain layer:
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-annotations</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-commons-annotations</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<scope>provided</scope>
</dependency>
Q2: why are these declared explicitly in our pom.xml? shouldn't one dependency on hibernate provides defaults for others.
Q3 Is the following an effective way of refactoring (using Jboss bom) ? Have one dependency in parent pom.xml and each modules just inherit from parent. In this way, child pom.xml is simplified and short. what is the downside of this? will I get all the dependencies I provided explicitly in each of REST and domain layer above.
<dependency>
<groupId>org.jboss.bom.eap</groupId>
<artifactId>jboss-javaee-6.0-with-resteasy</artifactId>
<version>${jboss.bom.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Upvotes: 2
Views: 812
Reputation: 7543
I think this will give you everything you need:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jboss.bom</groupId>
<artifactId>jboss-javaee-6.0-with-all</artifactId>
<version>1.0.7.Final</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jboss.spec</groupId>
<artifactId>jboss-javaee-all-6.0</artifactId>
<version>3.0.3.Final</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>xalan</groupId>
<artifactId>xalan</artifactId>
<version>2.7.2</version>
<scope>provided</scope>
</dependency>
</dependencies>
You get everything that is in Java EE 6 (all API's). If you want some functionality that is specific to RestEasy, you need to add dependencies for that.
The Xalan dependency is needed because of a bug, see this post.
For Java EE 7 on WildFly 8.2 use this dependencies:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.wildfly.bom</groupId>
<artifactId>jboss-javaee-7.0-with-all</artifactId>
<version>8.2.0.Final</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jboss.spec</groupId>
<artifactId>jboss-javaee-all-7.0</artifactId>
<version>1.0.2.Final</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
Upvotes: 2