简体   繁体   English

将一个 spring-boot 项目作为 jar 添加到另一个项目中

[英]Add one spring-boot project as a jar to another project

我有 spring-boot 项目,我打包成 JAR 文件,现在我想把这个 jar 文件添加到另一个项目中,我可以实现它吗?

You have to specify the main class in your maven configuration or gradle configuration.您必须在 Maven 配置或 gradle 配置中指定主类。 Also in any case exclude from scanning the main class and other classes that might cause conflicts.同样在任何情况下都排除扫描可能导致冲突的主类和其他类。

Same applies for your dependencies in case of conflicts.如果发生冲突,同样适用于您的依赖项。

(1) You must build Spring Boot application in JAR files (It's fat JAR, executable JAR file). (1) 您必须在 JAR 文件中构建 Spring Boot 应用程序(它是胖 JAR,可执行 JAR 文件)。 This JAR file has GAV (GroupId, Artifact and Version).这个 JAR 文件有 GAV(GroupId、Artifact 和 Version)。 You must run Maven install command to add this JAR file to local repository.您必须运行 Maven install 命令才能将此 JAR 文件添加到本地存储库。

(2) Use build tool (like Maven or Gradle) to add this file to dependency list in normal way. (2) 使用构建工具(如 Maven 或 Gradle)将此文件以正常方式添加到依赖项列表中。

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

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