Grizzly and Jersey standalone jar

后端 未结 3 969
慢半拍i
慢半拍i 2020-12-09 21:52

I am trying to package Grizzly with Jersey as a single jar using Maven shade plugin. But I always get the message No container provider supports the type class org.gla

3条回答
  •  一个人的身影
    2020-12-09 22:21

    The following links helped me figuring out the solution below:

    • http://maven.apache.org/guides/mini/guide-assemblies.html
    • http://maven.apache.org/plugins/maven-assembly-plugin/descriptor-refs.html
    • How can I merge resource files in a Maven assembly?

    especially the answer

    • https://stackoverflow.com/a/11331222/1497139

    Instead of using the jar-with-dependencies as the descriptorRef of your assembly-plugin configuration you create our own e.g. in src/assembly/depmerge.xml (see below). This assembly configuration will add a containerDescriptorHandler that cares for the META-INF/services.

    run

    mvn clean compile assembly:single
    

    to get a jar file in target which you can call with

    java -jar target/x.y.-version-jar-with-dependencies.jar
    

    pom.xml:

          
                maven-assembly-plugin
                2.5.3
                
                    
                        
                            ${mainClass}
                        
                    
              src/assembly/depmerge.xml
              
            
    

    src/assembly/depmerge.xml:

    
    
        
        jar-with-dependencies-and-services
        
            jar
        
        false
        
            
                /
                true
                true
                runtime
            
        
        
        
            
                metaInf-services
            
        
    
    

提交回复
热议问题