1

I am trying to use "swagger-jaxrs-maven" plugin to generate RESTful API docs from the source code.

I followed this web site: swagger-jaxrs-maven

but maven complained that it can't find this plugin, so I searched it on maven central repository

It only finds it under groupId com.greensopinion.swagger. So I changed it accordingly.

But now I get this error:

[ERROR] Failed to execute goal com.greensopinion.swagger:jaxrs-gen:1.3.0:generate (default) on project treaty: Execution default of goal com.greensopinion.swagg er:jaxrs-gen:1.3.0:generate failed: Unable to load the mojo 'generate' in the plugin 'com.greensopinion.swagger:jaxrs-gen:1.3.0' due to an API incompatibility: org.codehaus.plexus.component.repository.exception.ComponentLookupException: com/greensopinion/swagger/jaxrsgen/SwaggerJaxrsGeneratorMojo : Unsupported major.mi nor version 52.0

I cleaned all my local maven repository and re-tried, it doesn't work.

My maven is 3.2.3 and JDK is 1.7.

My RESTful framework is Jersey2.17 with Jackson.

Any suggestion on how to make it work?

Nicholas K
  • 15,148
  • 7
  • 31
  • 57
Justin
  • 1,050
  • 11
  • 26
  • 1
    *maven complain it can't find this plugin* Can you share what dependency you used? But the problem is that this is a plugin that uses Java 8. You can't use, this version at least, with JDK 7. This is what *Unsupported major.minor version 52.0* is telling you. – Tunaki Dec 05 '16 at 22:38
  • Thanks, Tunaki, it works after I switched to JDK 8. – Justin Dec 05 '16 at 23:21

2 Answers2

1

This issue is not related to swagger or maven but to your JDK version (version 52.0 means a JDK 8 is expected).

See https://stackoverflow.com/a/35866015/779338 for mode details.

Furthermore, if you download the pom.xml of swagger-jaxrs-maven available in maven central repository, you can see that a JDK8 (maven.compiler.source=1.8) has been used to generate a java 8 package (maven.compiler.target=1.8), then it can't be used with a JDK7.

Community
  • 1
  • 1
Nelson G.
  • 5,145
  • 4
  • 43
  • 54
0

I have following Maven dependencies, it turns out fine.

For Swagger, Phillip project which just plug and play.

    <dependency>
        <groupId>com.github.phillip-kruger</groupId>
        <artifactId>apiee-core</artifactId>
        <version>1.0.8</version>
    </dependency>

JAVA EE - JAX-RS api

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

Use JDK 1.8 or above. I use eclipse and wildly server.

nick
  • 610
  • 5
  • 11