org. apache .maven.plugins.enforcer.BanDuplicateClasses завершился ошибкой с сообщением: найдены повторяющиеся классы - PullRequest
0 голосов
/ 05 января 2020

Я добавил в свой проект следующую зависимость от Wiremock:

<dependency>
  <groupId>com.github.tomakehurst</groupId>
  <artifactId>wiremock-standalone</artifactId>
  <version>2.25.1</version>
  <scope>test</scope>
</dependency>

, которая завершается ошибкой:

[WARNING] Rule 0: org.apache.maven.plugins.enforcer.BanDuplicateClasses failed with message:
Duplicate classes found:

  Found in:
    org.slf4j:slf4j-api:jar:1.7.7:compile
    com.github.tomakehurst:wiremock-standalone:jar:2.25.1:test
  Duplicate classes:
    org/slf4j/helpers/SubstituteLogger.class
    org/slf4j/ILoggerFactory.class
    org/slf4j/helpers/BasicMDCAdapter.class
    org/slf4j/MDC.class
    org/slf4j/LoggerFactory.class
    org/slf4j/spi/MDCAdapter.class
    org/slf4j/helpers/Util.class
    org/slf4j/helpers/NOPLogger.class
    org/slf4j/helpers/NOPLoggerFactory.class
    org/slf4j/helpers/SubstituteLoggerFactory.class
    org/slf4j/helpers/NamedLoggerBase.class
    org/slf4j/helpers/NOPMDCAdapter.class
    org/slf4j/MarkerFactory.class
    org/slf4j/Logger.class
    org/slf4j/Marker.class
    org/slf4j/helpers/FormattingTuple.class
    org/slf4j/helpers/BasicMarker.class
    org/slf4j/spi/LoggerFactoryBinder.class
    org/slf4j/helpers/MarkerIgnoringBase.class
    org/slf4j/spi/LocationAwareLogger.class
    org/slf4j/helpers/MessageFormatter.class
    org/slf4j/helpers/BasicMarkerFactory.class
    org/slf4j/IMarkerFactory.class
    org/slf4j/spi/MarkerFactoryBinder.class

[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  2.197 s
[INFO] Finished at: 2020-01-05T17:45:50Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-enforcer-plugin:1.1.1:enforce (enforce-maven) on project project-webapp: Some Enforcer rules have failed. Look above for specific messages explaining why the rule failed. -> [Help 1]

Итак, я добавляю исключение:

<dependency>
  <groupId>com.github.tomakehurst</groupId>
  <artifactId>wiremock-standalone</artifactId>
  <version>2.25.1</version>
  <exclusions>
    <exclusion>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
    </exclusion>
  </exclusions>
  <scope>test</scope>
</dependency>

Но я получаю то же сообщение об ошибке. Правильно ли мое исключение? Я строю проект с помощью команды mvn clean compile

1 Ответ

1 голос
/ 05 января 2020

Основываясь на проекте, я вижу, что wiremock-standalone представляет собой jar-шейд, что означает, что он содержит несколько файлов jar, включенных в один jar-файл ... в конце концов, вы ничего не можете исключить. Единственный выбор, который у вас есть, это проверить, можете ли вы использовать другой файл jar вместо -standalone ...

. Вы можете посмотреть файл jar:

unzip -t  wiremock-standalone-2.25.1.jar
 ..
testing: org/                     OK
testing: org/slf4j/               OK
testing: org/slf4j/event/         OK
testing: org/slf4j/event/EventConstants.class   OK
testing: org/slf4j/event/EventRecodingLogger.class   OK
testing: org/slf4j/event/Level.class   OK
testing: org/slf4j/event/LoggingEvent.class   OK
testing: org/slf4j/event/SubstituteLoggingEvent.class   OK
testing: org/slf4j/helpers/       OK
testing: org/slf4j/helpers/BasicMarker.class   OK
testing: org/slf4j/helpers/BasicMarkerFactory.class   OK
testing: org/slf4j/helpers/BasicMDCAdapter$1.class   OK
testing: org/slf4j/helpers/BasicMDCAdapter.class   OK
testing: org/slf4j/helpers/FormattingTuple.class   OK
testing: org/slf4j/helpers/MarkerIgnoringBase.class   OK
testing: org/slf4j/helpers/MessageFormatter.class   OK
testing: org/slf4j/helpers/NamedLoggerBase.class   OK
testing: org/slf4j/helpers/NOPLogger.class   OK
testing: org/slf4j/helpers/NOPLoggerFactory.class   OK
testing: org/slf4j/helpers/NOPMDCAdapter.class   OK
testing: org/slf4j/helpers/SubstituteLogger.class   OK
testing: org/slf4j/helpers/SubstituteLoggerFactory.class   OK
testing: org/slf4j/helpers/Util$1.class   OK
testing: org/slf4j/helpers/Util$ClassContextSecurityManager.class   OK
testing: org/slf4j/helpers/Util.class   OK
testing: org/slf4j/ILoggerFactory.class   OK
testing: org/slf4j/IMarkerFactory.class   OK
testing: org/slf4j/Logger.class   OK
testing: org/slf4j/LoggerFactory.class   OK
testing: org/slf4j/Marker.class   OK
testing: org/slf4j/MarkerFactory.class   OK
testing: org/slf4j/MDC$1.class    OK
testing: org/slf4j/MDC$MDCCloseable.class   OK
testing: org/slf4j/MDC.class      OK
testing: org/slf4j/spi/           OK
testing: org/slf4j/spi/LocationAwareLogger.class   OK
testing: org/slf4j/spi/LoggerFactoryBinder.class   OK
testing: org/slf4j/spi/MarkerFactoryBinder.class   OK
testing: org/slf4j/spi/MDCAdapter.class   OK
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...