简体   繁体   English

如何打包 gradle 多模块 Spring Boot 应用程序以供其他项目使用?

[英]How to package gradle multi-module spring boot app for other project to use?

I have a gradle spring boot project with multiple modules and want to build it as a jar file so that I can reuse the methods from different modules in other projects.我有一个带有多个模块的 gradle spring boot 项目,并希望将其构建为 jar 文件,以便我可以在其他项目中重用来自不同模块的方法。

I used java-library plugin in the build.gradle of the root path and packaged it as a jar.我在根路径的build.gradle中使用了java-library插件,打包成jar。 But when I imported it into my other applications as a dependency, the jar files of each module under BOOT-INF/libs are not accessible and the methods I called can't be located.但是当我将它作为依赖项导入到我的其他应用程序中时,无法访问BOOT-INF/libs下的每个模块的 jar 文件,并且无法找到我调用的方法。

Is there any way I can make each module reusable for other applications?有什么方法可以使每个模块可重用于其他应用程序?

You can manage projects as module and use them on importing您可以将项目作为模块管理并在导入时使用它们

Check this link: https://stackoverflow.com/a/69660601/7505687检查此链接: https ://stackoverflow.com/a/69660601/7505687

If you need to share spring boot beans ammong them use @ComponentScan如果您需要在其中共享 Spring Boot bean,请使用@ComponentScan

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在多模块 Gradle 项目中构建分发包? - How to build distribution package in multi-module Gradle project? 如何使用Proguard混淆多模块spring-boot项目? - How to obfuscate multi-module spring-boot project with proguard? 找不到包裹(多模块弹簧项目) - Package not found (Multi-module spring project) 如何将 test 和 main 的属性注入多模块 gradle spring boot 项目的每个子模块? - How can I inject properties for test and for main into each sub module of a multi-module gradle spring boot project? Spring Boot-如何从多模块项目中的姐妹模块启动Spring Boot Application? - Spring Boot - How to start my Spring Boot Application from sister module in a multi-module project? 从 Gradle 多模块项目构建的 Jar 使用 Spring 启动不起作用 - Jar built from Gradle multi-module project with Spring Boot doesn't work 如何将Spring ROO与maven多模块项目一起使用? - How to use Spring ROO with a maven multi-module project? 用于Gradle多模块项目的Spring Platform Bom - Spring platform bom for Gradle multi-module project 多模块maven项目中的Spring启动配置 - Spring boot configuration in a multi-Module maven project 多模块 spring-boot 项目上的 Surefire - Surefire on multi-module spring-boot project
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM