简体   繁体   English

如何使用 maven 的 spring 引导应用程序的构建库 jar

[英]How a build library jar of spring boot application using maven

I have an application A which contains code to fetch records from dB and some other functionality.我有一个应用程序 A,其中包含从 dB 和其他一些功能中获取记录的代码。 I want to use the same in another project B and use A as dependency.我想在另一个项目 B 中使用它并使用 A 作为依赖项。 Even if spring boot apps are not recommended to be used as library I have this use case bcs app A is a batch application and doesn't keep running so no option of rest call.即使不建议将 spring 引导应用程序用作库,我也有此用例 bcs 应用程序 A 是批处理应用程序并且不会继续运行,因此没有 rest 调用选项。 Issue is when I try to create the jar it is created as spring boot jar or if I create a normal jar it doesn't have the required dependencies and fails at runtime as class not found. Issue is when I try to create the jar it is created as spring boot jar or if I create a normal jar it doesn't have the required dependencies and fails at runtime as class not found. It seems dependencies from parent project of A are not included during jar creation.在 jar 创建期间似乎不包括来自 A 的父项目的依赖项。 Is there a recommenced way of generating the jar using maven.是否有使用 maven 生成 jar 的推荐方法。

To elaborate on what chrylis said:详细说明 chrylis 所说的话:

Create a project or module C that contains everything that both A and B need.创建一个项目或模块 C,其中包含 A 和 B 所需的一切。 Use it as dependency in A and B.将其用作 A 和 B 中的依赖项。

The easiest way to handle this is to have a multi-module-project with A, B and C, but you can also have three separate projects.处理此问题的最简单方法是拥有一个包含 A、B 和 C 的多模块项目,但您也可以拥有三个独立的项目。

暂无
暂无

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

相关问题 如何使用Maven插件正确构建Spring Boot far jar? - How to properly build a Spring Boot far jar using maven plugin? 具有jar依赖项的Spring Boot应用程序在Maven构建后无法运行 - Spring Boot application with a jar dependency does not run after maven build 如何为我的Java应用程序+ mysql创建可安装文件(从maven build spring boot创建的jar) - How to create installable for my java application + mysql (jar created from maven build spring boot) 如何使用 maven 将 spring-boot 打包到带有本地 jar 的 jar - How to package spring-boot to jar with local jar using maven 使用 Spring Boot Maven 插件时,jar 文件中缺少 Spring Boot 应用程序中的资源 - resources in a Spring Boot application are missing from jar file when using Spring Boot Maven Plugin 当我用Jenkins用Maven构建Spring Boot应用程序并执行JAR文件时,找不到类定义? - Can not find class define, when I build a Spring Boot application with Maven by Jenkins and execute JAR file? 如何使用 Spring Boot 和 Maven 从 RPM 构建中排除 application.properties - How to exclude application.properties from RPM build using Spring Boot and Maven 如何使用Spring Boot制作非可执行库(jar)? - How to make non executable library (jar) using spring boot? 如何使用Maven构建jar? - How to build a jar using Maven? Spring 启动 maven 构建不包括最终 jar 中的工件版本 - Spring boot maven build not including artifact version in final jar
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM