简体   繁体   English

用本地类替换提供的Maven依赖项

[英]Replace provided Maven dependency with local class

If I check my effective pom I will find the following entry: 如果我检查有效的pom,我将找到以下条目:

  <dependency>
    <groupId>com.package.of.other.department</groupId>
    <artifactId>someArtifact</artifactId>
    <version>2.4.2</version>
    <scope>provided</scope>
  </dependency>

This comes from the parent pom that we have to use to let our software (bpmn processes) run on a company wide platform. 这来自父pom,我们必须使用它来使我们的软件(bpmn进程)在公司范围的平台上运行。

Now comes a hacky part. 现在是一个很棘手的部分。 There will be a bigger change and we cannot use someArtifact anymore. 会有更大的变化,我们不能再使用someArtifact Unfortunately that artifact gets called directly by all our processes (you design the process and configure the full qualified class name for an item) and can't just configure a different artifact, as that would most likely break a lot of the running processes. 不幸的是,我们的所有流程都直接调用了工件(您可以设计流程并配置项目的完整合格类名称),而不能仅配置其他工件,因为这很可能会破坏许多正在运行的流程。

The simple plan was to create a class with the same package name and with the same class name, remove every dependency to the original package and everything should work fine. 一个简单的计划是创建一个具有相同程序包名称和相同名称的类,删除对原始程序包的所有依赖关系,然后一切正常。 During the tests I noticed that it doesn't use my new class but still the original one, most likely because it gets provided as dependency via the mandatory parent pom and for some reason prefers that over my local one. 在测试期间,我注意到它不使用我的新类,但仍使用原始类,这很可能是因为它是通过强制性父pom作为依赖项提供的,由于某种原因,它比我的本地类更喜欢。

Excluding a provided dependency from the parent pom doesn't seem to work that easily?! 从父pom排除提供的依赖似乎不那么容易? Any idea how I could solve my issue? 知道如何解决问题吗?

If the application is regular java, the class that will be load is the first class met in the classpath order. 如果应用程序是常规Java,则将要加载的类是按类路径顺序遇到的第一个类。

If you use other runtime package dependency management, the strategy is different. 如果使用其他运行时程序包依赖项管理,则策略将有所不同。 As example you can adjust your import-package in OSGi to ensure the use a class contains in private-package. 例如,您可以在OSGi中调整导入包,以确保使用私有包中包含的类。

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

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