Spring Boot Maven Plugin - No BOOT-INF directory

前端 未结 5 997
耶瑟儿~
耶瑟儿~ 2020-12-05 21:44

Between version 1.3.8.RELEASE of the spring-boot-maven-plugin and version 1.4.0.RELEASE - there has been a change in the generated package structure (if you extract the uber

5条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-05 22:08

    The answer above with

    MODULE
    

    does not work anymore, this is because layout element is deprecated in Spring Boot 2.x. I am using Spring Boot 2.0.x, I found this helpful comment on github:

    Support for the module layout was removed in Spring Boot 2.0 having been deprecated in 1.5. Unfortunately, the updates to the Maven Plugin's documentation were missed so we can use this issue to sort that out. You should use a custom LayoutFactory instead.

    But as I did not want to implement LayoutFactory I tried this second solution below that actually repackage and creates an extra jar with a classifier given name:

    This is due to the change in layout of executable jars in Spring Boot 1.4. Application classes are now packaging in BOOT-INF/classes. Your client module depends on the repackaged, fat jar of your web module. Due to the new layout that means that the client module can no longer load the web module's classes. If you want to use your web module as a dependency, you should configure Boot's repackaging to apply a classifier to the fat jar. For example:

    
        
            
                org.springframework.boot
                spring-boot-maven-plugin
                
                    
                        
                            repackage
                        
                        
                            exec
                        
                    
                
            
        
    
    

    Doing so will allow other modules to depend on the original jar that does not embed the module's dependencies and has the classes at the root of the jar.

    One original jar have the same structure as I wanted like

    com.my-package.foo.bar
    META-INF
    

    and the second classifier have the newer structure with BOOT-INF/ etc.

提交回复
热议问题