Как исключить внутренний пакет (не maven зависимость) из зависимостей в Gradle - PullRequest
0 голосов
/ 18 октября 2019

Мой проект является проектом с загрузочной пружиной и имеет зависимость, равную dexkiller, однако dexkiller полагается на soot-infoflow-cmd-jar-with-dependencies, который внутренне использует slf4j, в то время как мой проект с загрузочной пружиной также использует slf4j.
Таким образом, выполняется следующееошибка при запуске моего проекта.
Ошибка:

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/Users/user/.gradle/caches/modules-2/files-2.1/de.tud.sse/soot-infoflow-cmd-jar-with-dependencies/1.0/75ee1aee22aee20d41153e43b16b874caa927d2c/soot-infoflow-cmd-jar-with-dependencies-1.0.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/Users/user/.gradle/caches/modules-2/files-2.1/ch.qos.logback/logback-classic/1.2.3/7c4f3c474fb2c041d8028740440937705ebb473a/logback-classic-1.2.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.SimpleLoggerFactory]
Exception in thread "main" java.lang.IllegalArgumentException: LoggerFactory is not a Logback LoggerContext but Logback is on the classpath. Either remove Logback or the competing implementation (class org.slf4j.impl.SimpleLoggerFactory loaded from file:/Users/user/.gradle/caches/modules-2/files-2.1/de.tud.sse/soot-infoflow-cmd-jar-with-dependencies/1.0/75ee1aee22aee20d41153e43b16b874caa927d2c/soot-infoflow-cmd-jar-with-dependencies-1.0.jar). If you are using WebLogic you will need to add 'org.slf4j' to prefer-application-packages in WEB-INF/weblogic.xml: org.slf4j.impl.SimpleLoggerFactory
    at org.springframework.util.Assert.instanceCheckFailed(Assert.java:655)
    at org.springframework.util.Assert.isInstanceOf(Assert.java:555)
    at org.springframework.boot.logging.logback.LogbackLoggingSystem.getLoggerContext(LogbackLoggingSystem.java:280)
    at org.springframework.boot.logging.logback.LogbackLoggingSystem.beforeInitialize(LogbackLoggingSystem.java:104)
    at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationStartingEvent(LoggingApplicationListener.java:219)
    at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEvent(LoggingApplicationListener.java:200)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:127)
    at org.springframework.boot.context.event.EventPublishingRunListener.starting(EventPublishingRunListener.java:70)
    at org.springframework.boot.SpringApplicationRunListeners.starting(SpringApplicationRunListeners.java:47)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:302)

Дерево зависимостей, как показано ниже (сажа * баночки из моего репозитория Nexus):

+--- com.mywork:dexkiller:1.3.1-SNAPSHOT
|    +--- commons-collections:commons-collections:3.2
|    +--- cde.tud.sse:soot-infoflow-cmd-jar-with-dependencies:2.7
|    \--- cde.tud.sse:soot-infoflow-summaries-classes:2.7

Извлеченофайлы из soot-infoflow-cmd-jar-with-dependencies.jar

Extracted files

Я пытался исключить slf4j из dexkiller, но не работает.

dependencies {
    compile ('com.mywork:dexkiller:1.3.1-SNAPSHOT'){
            // tried both them and each of them, neither work
            exclude group:'org.slf4j'
            exclude group:'org.apache.logging.log4j', module:'log4j-slf4j-impl'
    }
}

тоже так

configurations.all {
    // tried both them and each of them, neither work
    exclude group: 'org.slf4j', module: 'dexkiller'
    exclude group:'org.apache.logging.log4j', module:'log4j-slf4j-impl'
}

Кто-то сказал мне попробовать

configurations {
    compile.exclude module: 'spring-boot-starter-logging'
}

Он просто избежал множественных конфликтов привязок SLF4J, но я бы хотел использовать мой slf4j, а не slf4j изсажевые банки.

1 Ответ

0 голосов
/ 18 октября 2019

A jar-with-dependencies не следует использовать в качестве зависимости. Если у вас есть влияние на это, исправьте это. В противном случае вы можете попытаться исключить весь jar с зависимостями и снова добавить включенные зависимости, пока ваш проект не заработает.

...