简体   繁体   English

抑制本地存储库中的 maven 依赖版本后缀

[英]Suppress maven dependency version suffix in local repository

I have a Spring Boot project that uses SAP Crystal Reports.我有一个使用 SAP Crystal Reports 的 Spring Boot 项目。 CR is not published in Maven Central. CR 未在 Maven Central 中发布。 I imported all of the CR jar files into my Maven local repository.我将所有 CR jar 文件导入到我的 Maven 本地存储库中。 In my projects the jars have the version appended to the jar file name.在我的项目中,jar 将版本附加到 jar 文件名。 For one jar file, this causes a runtime error.对于一个 jar 文件,这会导致运行时错误。 How can I have that jar not have the appended Maven version?我怎样才能让那个 jar 没有附加的 Maven 版本?

if you build from source using Maven then you can override the artifact final name in the POM of this project如果您使用 Maven 从源代码构建,那么您可以在该项目的 POM 中覆盖工件最终名称

 <finalName>myJar</finalName>

If you run the mvn install manually then you have control of what you store into the Maven repository如果您手动运行 mvn install,那么您可以控制存储到 Maven 存储库中的内容

 mvn install:install-file -Dfile=<path-to-file> -DgroupId=<group-id> \
-DartifactId=<artifact-id> -Dversion=<version> -Dpackaging=<packaging>

This is my workaround hack.这是我的解决方法黑客。

The Jar is question is never directly referenced by my project code, it is a runtime library of the Crystal Reports java runtime. Jar 是我的项目代码从未直接引用的问题,它是 Crystal Reports java 运行时的运行时库。 I do not need it in the classpath at build time, just in the deployed file built by maven.我在构建时的类路径中不需要它,只是在 maven 构建的部署文件中。

My Spring Boot project is deployed as a WAR file so I need to structure my Eclipse Maven project so that the Jar is placed in WEB-INF/lib as a plain web app resource.我的 Spring Boot 项目部署为 WAR 文件,因此我需要构建我的 Eclipse Maven 项目,以便将 Jar 作为普通 Web 应用程序资源放置在 WEB-INF/lib 中。 I do not specify the jar as a maven dependency.我没有将 jar 指定为 maven 依赖项。

It's a hack because the jar file IS a dependency and SHOULD be specified as a maven project dependency in the pom.xml.这是一个 hack,因为 jar 文件是一个依赖项,应该在 pom.xml 中指定为 maven 项目依赖项。

This solves my immediate problem.这解决了我眼前的问题。 I blame SAP for not considering Maven for their Crystal Reports Java runtime.我责怪 SAP 没有将 Maven 用于他们的 Crystal Reports Java 运行时。

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

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