resteasy providers missing after mvn package

前端 未结 2 1598
一向
一向 2020-12-11 23:15

I have written some code that uses some resteasy libraries.

The code works fine in Eclipse but produces exceptions when excecuted as fat-jar build with the maven sha

相关标签:
2条回答
  • 2020-12-11 23:21

    The accepted answer is correct, but is for Maven's Shade plugin. If you're using Gradle's Shadow plugin, you must merge service descriptor files.

    Using Gradle's Kotlin DSL:

    tasks {
        withType<ShadowJar> { mergeServiceFiles() }
    }
    

    Using Gradle's Groovy DSL:

    shadowJar { mergeServiceFiles() }
    
    0 讨论(0)
  • 2020-12-11 23:33

    Ok, i found the solution.

    Maven shade plugin allows you to force append files that are identically named...

    So what the maven-shade-plugin in the pom.xml lags is:

    <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
      <resource>META-INF/services/javax.ws.rs.ext.Providers</resource>
    </transformer>
    

    https://maven.apache.org/plugins/maven-shade-plugin/examples/resource-transformers.html#AppendingTransformer

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