Spring Boot“Thinner Fat Jar” - 将 jar 分成 2 个(应用程序/库)
我想将我的应用程序分成 2 个胖罐子(模块/库)。
我已经检查过“Spring Boot Thin jar 项目”,它加载依赖项并在第一次运行时缓存它们,但我无法使其与多个本地模块一起使用。
不过...我更愿意让我的第一种方法发挥作用。有什么想法吗?
Gradle 6.9.1(7.x 不适用于 Thin jar)
Spring Boot 2.6.x
编辑 (2022-02)
检查下面的解决方案...
I would like to split my app into 2 fat jars (modules/libraries).
I've checked already the "Spring Boot thin jar project", which loads the dependencies and caches them on first run but I cant make it work with multiple local modules.
Still... I would prefer to make my first approach work. Any ideas?
Gradle 6.9.1 (7.x not working with thin jar)
Spring Boot 2.6.x
Edited (2022-02)
Check my solution below...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
创建2个项目,构建时构建为2个JAR文件。
项目 1(fat JAR)对项目 2 的引用。
Spring Boot fat JAR(已嵌入 Tomcat),将调用另一个 JAR。
Create 2 projects, when build, build to 2 JAR file.
Project 1 (fat JAR) reference to Project 2.
Spring Boot fat JAR (has embed Tomcat), will call another JAR.
我设法做了我想做的事。
为此,我必须将 gradle 中的 bootJar 任务扩展为 2 个任务,一个用于依赖项,另一个用于我的库......
依赖项中的 mainClass 没有用,但仍然是该任务所必需的。
I managed to do what I wanted.
For that purpose, I had to extend the bootJar task in gradle into 2 tasks, one for the dependencies, and one for my libraries...
The mainClass in the dependencies is useless, but still required for the task.