【发布时间】:2019-01-09 17:16:08
【问题描述】:
我有一个多模块项目:
Root project 'platform'
+--- Project ':api'
+--- Project ':common'
在:common 模块中我包含所有依赖项,在:api 模块中,我只有
apply(plugin = "org.springframework.boot")
dependencies {
implement(project(":common"))
}
问题是当我构建:api 模块时,从jar 文件中我看不到jar 文件中的任何依赖项,没有BOOT-INF/libs/ 只有BOOT-INF/classes/。
当我使用 java -jar 运行 jar 时,它显示 :common 模块中的一个类的 NoClassFound。
gradle :api:bootRun 工作正常。
我还有其他配置吗? 我正在使用 gradle 4.9 kotlin dsl 和 spring boot 插件 1.5.15.RELEASE
【问题讨论】:
-
正如你所说,
in the :common module I include all the dependencies, in the :api module, you don't have that。所以没有libs文件夹,因为那个。还有你想用它来服务什么目的,因为你可能在:api模块中不必要地添加了这些依赖项 -
@rdj7 我已经更新了问题,实际上我看到的问题是,当我运行 jar 时,它显示公共模块中的一个类的 NoClassFound。我将所有依赖项放在 common 模块中的原因是我实际上有两个模块都依赖于 common 模块而不仅仅是 api 模块。
标签: java spring-boot gradle