【发布时间】:2021-11-22 06:07:42
【问题描述】:
目标
我想将私有存储库用作其他 Spring Boot 项目中的库,方法是将其托管为 GitHub package。
图书馆项目
https://github.com/sagarnayak/privatecentralrepo
客户项目
https://github.com/sagarnayak/repoclientproject
复制步骤
库项目有一个 library001 模块。这是我想用作其他项目的库。
在库模块pom文件中,我添加了repackage执行目标。
......
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
<configuration>
<classifier>exec</classifier>
</configuration>
</execution>
</executions>
</plugin>
......
我想将该模块用作库并将其作为private GitHub package 托管。
当我在 library001 模块中执行 mvnw deploy 时,这应该会创建一个 exec jar 并推送到 GitHub 以在其他项目中使用该库。
Github 有这个 exec jar。
为了在客户端项目中使用 jar,我已将此作为依赖项添加到客户端项目中。
<dependency>
<groupId>com.sagar</groupId>
<artifactId>libraray001</artifactId>
<version>0.0.3-SNAPSHOT</version>
<classifier>exec</classifier>
</dependency>
这会使项目进入客户端项目的外部库部分。这有我想在库中使用的类(TestModel001)。
但是当我尝试将它导入到我想使用的任何类中时,它无法解析导入。
如何在这个项目中使用库项目?
【问题讨论】:
-
您是否尝试过 google 如何将 github 重新设置为 maaven repo?
-
Github项目成功拉到执行项目。我认为这没有任何问题。我认为这与我在库项目或实施项目中所做的设置有关。 @Antoniossss 我添加了来自实施项目外部库部分的屏幕截图。它有图书馆项目。
-
Library001是 Spring Boot 应用程序,不能用作消耗性库... -
在项目的根目录中也有代码,其中包装为
pom将不起作用,因为 pom 没有代码并且它不会编译等。 -
@khmarbaise 如何将 spring boot 项目用作消耗库?我已经尝试将执行添加到 lib 项目。 github.com/sagarnayak/privatecentralrepo/blob/… 到库 pom 文件。有什么建议吗?
标签: spring-boot maven kotlin github