Testing against Java EE 6 API

前端 未结 3 1141
小蘑菇
小蘑菇 2020-12-01 05:10

I write an addition to JAX-RS and included the Java EE 6 API as a Maven dependency.


    javax
    

        
相关标签:
3条回答
  • 2020-12-01 05:31

    As for me, JBoss' implementation is smaller than the whole Glassfish, so I'm using:

        <dependency>
            <groupId>org.jboss.spec</groupId>
            <artifactId>jboss-javaee-6.0</artifactId>
            <version>${version.jboss-javaee-6.0}</version>
            <type>pom</type>
        </dependency>
    

    <scope>test</scope> should also do no harm.

    0 讨论(0)
  • 2020-12-01 05:44

    Not sure this will solve your problem but GlassFish Embedded provides a Java EE 6 implementation. Add this to your pom.xml:

    <project>
      ...
      <repositories>
        <repository>
          <id>glassfish-extras-repository</id>
          <url>http://download.java.net/maven/glassfish/org/glassfish/extras</url>
        </repository>
      </repositories>
      ...
      <dependencies>
        <dependency>
          <groupId>org.glassfish.extras</groupId>
          <artifactId>glassfish-embedded-all</artifactId>
          <version>3.0.1</version>
          <scope>test</scope>
        </dependency>
        <dependency>
          <groupId>javax</groupId>
          <artifactId>javaee-api</artifactId>
          <version>6.0</version>
          <scope>provided</scope>
        </dependency>
        ...
      </dependencies>
      ...
    </project>
    

    It's important to declare the glassfish-embedded-all artifact before the javaee-api.

    0 讨论(0)
  • 2020-12-01 05:52

    An alternative that is JSR provider agnostic is

    <dependency>
      <groupId>javax.ws.rs</groupId>
      <artifactId>jsr311-api</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-api</artifactId>
        <version>6.0</version>
        <scope>provided</scope>
    </dependency>
    

    This allows you to swap Jersey with a different provider. For Glassfish 3.1.2, it uses jersey-server 1.11, which uses jsr311 version 1.1 according to the jersey pom.

    0 讨论(0)
提交回复
热议问题