javamavenjsr

Use only JSR api in my pom.xml


Well, i'm trying to follow the Oracle JSR and use only specifications in my project. I'm using JBOSS EAP 7 as Server APP.

1) I have hibernate dependency in my project:

 <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>${hibernate.core.version}</version>
        </dependency>

This is the correct way to follow specification (JSR) ? Or i should just set the JPA dependency without any hibernate dependency and let jboss take care about it ?

2) Another example: I'm using CDI, and in my project i have the WELD as implementation of CDI:

 <dependency>
            <groupId>org.jboss.weld</groupId>
            <artifactId>weld-core-jsf</artifactId>
            <version>2.3.3.Final</version>
        </dependency>

Should i replace it for a CDI-API dependency and let jboss takes care about implentation ?

What is the correct way to follow the JSR and go away from implementations ?


Solution

  • I haven't used JBoss EAP 7; but from its feature list it should implement Java EE 7 full profile. If that is the case, all that you need is the following Maven dependency:

    <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-api</artifactId>
        <version>7.0</version>
        <scope>provided</scope>
    </dependency>
    

    This should work as long as you deploy your application on one of full featured application servers (Wildfly/JBoss, Glassfish, Websphere,...) which support Java EE 7.