我有一个带有多个模块的spring boot gradle项目 . 父项目(元数据)只是子项目的根文件夹,有3个子项目(api,security和ui) .

  • security是一个使用spring安全性的独立项目 . 这是它的pom
dependencies {
     compile "org.springframework.boot:spring-boot-starter-security"
     compile "com.att.security:csp-cookies:1.0" 
    compile "javax.servlet:javax.servlet-api"
}
  • api项目使用安全项目中的一些类,因此它依赖于此
dependencies {
    compile ("org.springframework.boot:spring-boot-starter-data-rest") {
        exclude module: "spring-boot-starter-tomcat"
    }
    compile "org.apache.httpcomponents:httpclient:4.4"
    compile(project(":metadata-security")) 
}

3.最终UI项目是将所有内容组合在一起的可运行项目 .

dependencies {
        compile "org.springframework.boot:spring-boot-starter-thymeleaf"
        compile project(":api:metadata-api-invenio")
        compile(project(":metadata-security"))
    }

当我做gradle构建spring boot gradle插件时会为所有3个项目生成fat jar . 在解压缩jar文件时,似乎所有项目的所有传递deps都可以在fat jar里面的libs文件夹中找到 . 这很好但是由于某种原因,安全项目jar文件是一个胖jar并且在其lib文件夹中包含它的依赖项,这是不需要的 . 与此相反,api项目jar不是一个胖的,只包含它的类,因为它的 jar 已经在ui fat jar中可用了 .

任何创建安全项目jar的想法都与api项目不同 .