
SpringBoot 项目导入了本地特别的 jar, 通过 build.gradle 方式如下:
dependencies { implementation 'org.springframework.boot:spring-boot-starter-web' ...省略 compile files("libs/myjar.jar") } 然后启动 SpringBoot 时提示 slf4j 冲突如下:
SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/thePath/myjar.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/pop/projects/cncert/vehicle-engine/libs/DexKiller.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 然而尝试了 gradle exclude 也不好使。。。尝试如下:
dependencies { implementation 'org.springframework.boot:spring-boot-starter-web' ...省略 compile files("libs/myjar.jar"){ exclude group(或者 module):"org.slf4j" } } 然后随后把打成 jar 的工程里的直接用到 Logutils 都删了, 重新打包后查看 jar 里面资源, 还是有 org.slf4j, 可能是引用其他工具包的必要依赖吧。
v 友有解决方法吗?
1 rb6221 2019-09-20 11:10:02 +08:00 gradle 有全局的 exclude,不要在某个特定的包下面 exclude |
2 stephCurry OP @janus77 感谢解答,但是如果全局 exclude 那把 springboot 的 slf4j 也 exclude 掉了啊 |
3 C02TobNClov1Dz56 2019-09-20 15:54:03 +08:00 本地的 jar 对吧, 如果没有签名, 可以直接把本地 jar 的 slf4j 相关 class 和 package 都删了. |
4 C02TobNClov1Dz56 2019-09-20 15:54:55 +08:00 可以用 7zip 之类的软件打开 jar 包, 或者直接改后缀名为 zip |
5 wei745359223 2019-10-17 16:49:46 +08:00 configurations { compile.exclude module: 'spring-boot-starter-logging' } dependencies { .... } |
6 stephCurry OP @wei745359223 谢谢, 但是我想 exclude 的是被引用 jar 的 slf4j, 但是那个 jar 中的 slf4 无法 exclude, 因为那个 jar 里面的 package 里就有 org.slf4j, 好像除了找到那个文件源码删除有关 slf4j 的部分, 别无它法? |
7 stephCurry OP 找到了这个 jar 文件源码, 但是看了下通过修改源码的方式放弃了。。。。 https://github.com/secure-software-engineering/FlowDroid/releases#soot-infoflow-cmd-jar-with-dependencies.jar |