maven“薄罐”从私人gitlab存储库中赢得了拉库

发布于 2025-01-30 17:05:07 字数 3804 浏览 0 评论 0 原文

我有一个Java Spring Boot应用程序,该应用程序正在使用Spring Boot Maven Thin Jar插件包装到“薄罐”中。我遵循此处的说明 https://wwwww.baeldung.com/spring-boot-boot-thin -jar 一切都很好。我可以在轻量级罐子中部署我的应用程序的新版本,而运行该应用程序的生产服务器则保持自己的.m2存储库,并更新新的薄罐子是否列出了任何新的依赖项。

最近,我想包括我自己的外部图书馆。这是在Gitlab弹药软件包存储库中托管的,并通过访问令牌访问。我在此处设置此按照说明设置: 我已经写了一个 settings.xml ,并保存到 home/user/.m2/settings.xml ,其中包括访问令牌。

之后,任何 mvn ... 命令都按预期将库将库推入存储库。到目前为止,一切都很好。

但是,当我创建薄罐子并尝试使用 Java -jar -jar thin -jar.jar.jar.jar 运行时,它将无法获取库。错误如下:

$ java -Dthin.trace=true -jar thin-jar.jar
May 20, 2022 4:49:24 PM org.springframework.boot.loader.thin.ThinJarLauncher launch
INFO: Version: 1.0.28.RELEASE
May 20, 2022 4:49:24 PM org.springframework.boot.loader.thin.PathResolver resolve
INFO: Extracting dependencies from: jar:file:/home/user/thin-jar.jar!/, with profiles []
May 20, 2022 4:49:24 PM org.springframework.boot.loader.thin.PathResolver loadProperties
INFO: Searching for properties in: jar:file:/home/user/thin-jar.jar!/
May 20, 2022 4:49:24 PM org.springframework.boot.loader.thin.PathResolver loadProperties
INFO: Searching for properties in: classpath:/
May 20, 2022 4:49:24 PM org.springframework.boot.loader.thin.PathResolver loadProperties
INFO: Searching for properties in: file:./
May 20, 2022 4:49:24 PM org.springframework.boot.loader.thin.PathResolver extract
INFO: Extracting dependencies from: URL [jar:file:/home/user/thin-jar.jar!/META-INF/maven/my.group/thin-jar/pom.xml], with profiles []
May 20, 2022 4:49:24 PM org.springframework.boot.loader.thin.MavenSettingsReader loadSettings
INFO: Reading settings from: /home/user/.m2/settings.xml
May 20, 2022 4:49:24 PM org.springframework.boot.loader.thin.DependencyResolver dependencies
INFO: Computing dependencies from pom and properties
Exception in thread "main" java.lang.reflect.InvocationTargetException
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at org.springframework.boot.loader.wrapper.ThinJarWrapper.launch(ThinJarWrapper.java:139)
        at org.springframework.boot.loader.wrapper.ThinJarWrapper.main(ThinJarWrapper.java:107)
Caused by: java.lang.RuntimeException: Failed to read artifact descriptor for my.group:external-library:jar:0.0.1-dev
        at org.springframework.boot.loader.thin.DependencyResolver.dependencies(DependencyResolver.java:239)
        at org.springframework.boot.loader.thin.PathResolver.extract(PathResolver.java:259)
        at org.springframework.boot.loader.thin.PathResolver.resolve(PathResolver.java:105)
        at org.springframework.boot.loader.thin.ThinJarLauncher.getClassPathArchives(ThinJarLauncher.java:369)
        at org.springframework.boot.loader.thin.ThinJarLauncher.getClassPathArchives(ThinJarLauncher.java:352)
        at org.springframework.boot.loader.thin.ThinJarLauncher.getClassPathArchivesIterator(ThinJarLauncher.java:200)
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:55)
        at org.springframework.boot.loader.thin.ThinJarLauncher.launch(ThinJarLauncher.java:195)
        at org.springframework.boot.loader.thin.ThinJarLauncher.main(ThinJarLauncher.java:141)
        ... 6 more

我假设这是因为存储库是私人的,并且在尝试拉动该库时,身份验证在某个地方失败了?查看跟踪似乎正确加载了设置文件,所以出了哪里?

I have a java Spring Boot app which is being packaged into a "thin jar" using the spring boot maven thin jar plugin. I followed instructions from here https://www.baeldung.com/spring-boot-thin-jar and it's all working great. I can deploy new versions of my app in lightweight jars while the production server running the app maintains its own .m2 repository, updating if the new thin jar lists any new dependencies.

Recently I wanted to include my own external library. This is hosted in a gitlab-maven package repository and accessed via an access token. I set this up following instructions here: https://docs.gitlab.com/ee/user/packages/maven_repository/
I've written a settings.xml and saved to home/user/.m2/settings.xml which includes the access token.

After that any mvn ... command is pulling the library into the repository as expected. So far so good.

However when I create my thin jar and try to run with java -jar thin-jar.jar it fails to get the library. The error is as follows:

$ java -Dthin.trace=true -jar thin-jar.jar
May 20, 2022 4:49:24 PM org.springframework.boot.loader.thin.ThinJarLauncher launch
INFO: Version: 1.0.28.RELEASE
May 20, 2022 4:49:24 PM org.springframework.boot.loader.thin.PathResolver resolve
INFO: Extracting dependencies from: jar:file:/home/user/thin-jar.jar!/, with profiles []
May 20, 2022 4:49:24 PM org.springframework.boot.loader.thin.PathResolver loadProperties
INFO: Searching for properties in: jar:file:/home/user/thin-jar.jar!/
May 20, 2022 4:49:24 PM org.springframework.boot.loader.thin.PathResolver loadProperties
INFO: Searching for properties in: classpath:/
May 20, 2022 4:49:24 PM org.springframework.boot.loader.thin.PathResolver loadProperties
INFO: Searching for properties in: file:./
May 20, 2022 4:49:24 PM org.springframework.boot.loader.thin.PathResolver extract
INFO: Extracting dependencies from: URL [jar:file:/home/user/thin-jar.jar!/META-INF/maven/my.group/thin-jar/pom.xml], with profiles []
May 20, 2022 4:49:24 PM org.springframework.boot.loader.thin.MavenSettingsReader loadSettings
INFO: Reading settings from: /home/user/.m2/settings.xml
May 20, 2022 4:49:24 PM org.springframework.boot.loader.thin.DependencyResolver dependencies
INFO: Computing dependencies from pom and properties
Exception in thread "main" java.lang.reflect.InvocationTargetException
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at org.springframework.boot.loader.wrapper.ThinJarWrapper.launch(ThinJarWrapper.java:139)
        at org.springframework.boot.loader.wrapper.ThinJarWrapper.main(ThinJarWrapper.java:107)
Caused by: java.lang.RuntimeException: Failed to read artifact descriptor for my.group:external-library:jar:0.0.1-dev
        at org.springframework.boot.loader.thin.DependencyResolver.dependencies(DependencyResolver.java:239)
        at org.springframework.boot.loader.thin.PathResolver.extract(PathResolver.java:259)
        at org.springframework.boot.loader.thin.PathResolver.resolve(PathResolver.java:105)
        at org.springframework.boot.loader.thin.ThinJarLauncher.getClassPathArchives(ThinJarLauncher.java:369)
        at org.springframework.boot.loader.thin.ThinJarLauncher.getClassPathArchives(ThinJarLauncher.java:352)
        at org.springframework.boot.loader.thin.ThinJarLauncher.getClassPathArchivesIterator(ThinJarLauncher.java:200)
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:55)
        at org.springframework.boot.loader.thin.ThinJarLauncher.launch(ThinJarLauncher.java:195)
        at org.springframework.boot.loader.thin.ThinJarLauncher.main(ThinJarLauncher.java:141)
        ... 6 more

I'm assuming this is because the repository is private and somewhere along the way the authentication is failing while trying to pull that library? Looking at the trace it appears to load the settings file properly, so where is it going wrong?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文