gpt4 book ai didi

java - 使用 'mvn spring-boot:run' 时出错;但不适用于 java -jar 或 intelliJ

转载 作者:行者123 更新时间:2023-11-30 10:08:13 24 4
gpt4 key购买 nike

mvn clean install - builds successfully.

java -jar - app runs successfully.

mvn spring-boot:run - throws an error:

Detected both log4j-over-slf4j.jar AND bound slf4j-log4j12.jar on the class path, preempting StackOverflowError. See also http://www.slf4j.org/codes.html#log4jDelegationLoop for more details.

[INFO] Building Application 3.1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] >>> spring-boot-maven-plugin:2.1.1.RELEASE:run (default-cli) > test-compile @ service-app >>>
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ service-app ---`enter code here`
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 5 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ service-app ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ service-app ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Users\name\workspace\project\service-app\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ service-app ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] <<< spring-boot-maven-plugin:2.1.1.RELEASE:run (default-cli) < test-compile @ service-app <<<
[INFO]
[INFO]
[INFO] --- spring-boot-maven-plugin:2.1.1.RELEASE:run (default-cli) @ service-app ---
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/C:/Users/name/.m2/repository/org/slf4j/slf4j-log4j12/1.7.25/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/C:/Users/name/.m2/repository/ch/qos/logback/logback-classic/1.1.11/logback-classic-1.1.11.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Detected both log4j-over-slf4j.jar AND bound slf4j-log4j12.jar on the class path, preempting StackOverflowError.
SLF4J: See also http://www.slf4j.org/codes.html#log4jDelegationLoop for more details.
[WARNING]
java.lang.reflect.InvocationTargetException

What is mvn spring-boot:run doing differently?

[错误] 无法在项目服务应用程序上执行目标 org.springframework.boot:spring-boot-maven-plugin:2.1.1.RELEASE:run (default-cli):运行时发生异常。 null:InvocationTargetException:ExceptionInInitializerError:在类路径上检测到 log4j-over-slf4j.jar 和绑定(bind) slf4j-log4j12.jar,抢占 StackOverflowError。另见 http://www.slf4j.org/codes.html#log4jDelegationLoop更多细节。 -> [帮助1]

最佳答案

Detected both log4j-over-slf4j.jar AND bound slf4j-log4j12.jar on the class path, preempting StackOverflowError. See also http://www.slf4j.org/codes.html#log4jDelegationLoop for more details.

您看到这个是因为您的类路径中有多个 SLF4J Logger 实现。您必须清理您的 POM 文件并仅保留一个实现。

您可以尝试排除冲突的依赖项,

<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
<exclusion>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</exclusion>
</exclusions>

关于java - 使用 'mvn spring-boot:run' 时出错;但不适用于 java -jar 或 intelliJ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53841200/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com