简体   繁体   中英

Dependencies put twice into Spring Boot (>2.x) jar when using Gradle

adding Cloud SDK like this for CF: compile "com.sap.cloud.s4hana:s4hana-all:${cloudSDKVersion}" compile ("com.sap.cloud.s4hana.cloudplatform:scp-cf:${cloudSDKVersion}") leads to duplicate jars in spring boot jar which is deployed to CF. examples: core-2.3.1.jar connectivity-2.3.1.jar

  • This leads to :
    • ClassNotFoundExceptions during runtime
    • prevents cf push commands with error: Comparing local files to remote cache... Aborting push: File BOOT-INF/lib/core-2.3.1.jar has been modified since the start of push. Validate the correct state of the file and try again. FAILED Comparing local files to remote cache... Aborting push: File BOOT-INF/lib/core-2.3.1.jar has been modified since the start of push. Validate the correct state of the file and try again. FAILED

gradle skips the component name when building the boot package.

After some googling around this was the solution: https://github.com/spring-projects/spring-boot/issues/10778

bootJar {
    rootSpec.filesMatching('**/*.jar', { jar ->
        String groupId = jar.file.parentFile.parentFile.parentFile.parentFile.name
        jar.name = "$groupId-${jar.name}"
    })
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM