[英]Forcing maven spring boot project to use older version of a dependency instead of a new version from another dependency
I'm running in to a problem where I cannot start a spring boot server due to the same problem listed in this question: 由于此问题中列出的问题相同,我遇到了无法启动Spring启动服务器的问题:
How to set up Spring Boot and log4j2 properly? 如何正确设置Spring Boot和log4j2?
I am encountering this scenario because the spring boot project has a dependency on a jar that includes elasticsearch, which includes a new version of slf4j that isn't compatible with spring boot 我遇到这种情况是因为spring boot项目依赖于包含elasticsearch的jar,其中包括与spring boot不兼容的新版本的slf4j
I tried the recommended solution by implementing every exclusion in the elasticsearch project dependency definition possible, but for some reason the new version keeps being picked up. 我通过在elasticsearch项目依赖项定义中实现每个排除项来尝试推荐的解决方案,但由于某种原因,新版本仍然被选中。 I cannot seem to force the spring boot project to ignore the logging packages used by the elasticsearch project.
我似乎无法强制spring boot项目忽略elasticsearch项目使用的日志包。
Here is my pom for the spring-boot project, see the dependency for problematic.project.import : http://pastebin.com/Yeq2qk9Y 这是我的spring-boot项目的pom,请参阅problematic.project.import的依赖项: http : //pastebin.com/Yeq2qk9Y
Here is the pom for the project that is being imported into the spring boot project: http://pastebin.com/gknmf6Tt 这是导入春季启动项目的项目的pom: http : //pastebin.com/gknmf6Tt
The error I am getting is: 我得到的错误是:
Caused by: java.lang.NoSuchMethodError: org.apache.logging.log4j.core.config.ConfigurationFactory.getConfiguration(Lorg/apache/logging/log4j/core/config/ConfigurationSource;)Lorg/apache/logging/log4j/core/config/Configuration;
at org.springframework.boot.logging.log4j2.Log4J2LoggingSystem.loadConfiguration(Log4J2LoggingSystem.java:165)
at org.springframework.boot.logging.log4j2.Log4J2LoggingSystem.loadDefaults(Log4J2LoggingSystem.java:148)
at org.springframework.boot.logging.AbstractLoggingSystem.initializeWithConventions(AbstractLoggingSystem.java:75)
at org.springframework.boot.logging.AbstractLoggingSystem.initialize(AbstractLoggingSystem.java:50)
Any tips on how to get this issue cleared? 有关如何解决此问题的任何提示已被清除? Is this possible for two versions of this set of libraries to be loaded, each module ignorant to the version they don't need?
这个库的两个版本是否可以加载,每个模块都不知道他们不需要的版本?
You can exclude the cyclic dependencies by using the <exclusions>
tag in your pom.xml
like this: 您可以使用
pom.xml
的<exclusions>
标记排除循环依赖项,如下所示:
<dependency>
<groupId>sample.ProjectB</groupId>
<artifactId>Project-B</artifactId>
<version>1.0-SNAPSHOT</version>
<exclusions>
<exclusion>
<groupId>sample.ProjectE</groupId> <!-- Exclude Project-E from Project-B -->
<artifactId>Project-E</artifactId>
</exclusion>
</exclusions>
</dependency>
You should exclude the cyclic dependency of the newer version from the dependency which is having it and that way only the older version will be loaded and not both. 您应该从具有它的依赖项中排除较新版本的循环依赖性,这样只会加载旧版本而不是两者。
Here is the link for more information: 以下是获取更多信息的链接:
https://maven.apache.org/guides/introduction/introduction-to-optional-and-excludes-dependencies.html https://maven.apache.org/guides/introduction/introduction-to-optional-and-excludes-dependencies.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.