我尝试使用Sping Boot 2.3.4.RELEASE(最新版本)运行log4j 2.13.3(最新版本),但在启动应用程序时出现以下错误:
mix-data-collector_1 | ------------------------------------------------------------------------
mix-data-collector_1 | OpenJDK 64-Bit Server VM warning: Ignoring option PermSize; support was removed in 8.0
mix-data-collector_1 | DB update completed
mix-data-collector_1 | DB migration finished
mix-data-collector_1 | Start Mix Data Collector---------------------------------------------
mix-data-collector_1 | Listening for transport dt_socket at address: 5555
mix-data-collector_1 | Exception in thread "main" java.lang.reflect.InvocationTargetException
mix-data-collector_1 | at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
mix-data-collector_1 | at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
mix-data-collector_1 | at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
mix-data-collector_1 | at java.base/java.lang.reflect.Method.invoke(Method.java:566)
mix-data-collector_1 | at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48)
mix-data-collector_1 loader.Launcher.launch(Launcher.java:87)
mix-data-collector_1 | at org.springframework.boot.loader.Launcher.launch(Launcher.java:50)
mix-data-collector_1 | at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51)
mix-data-collector_1 | Caused by: java.lang.NoClassDefFoundError: org/apache/logging/log4j/util/StackLocator$FqcnCallerLocator
mix-data-collector_1 | at org.apache.logging.log4j.util.StackLocator.<clinit>(StackLocator.java:37)
mix-data-collector_1 | at org.apache.logging.log4j.util.StackLocatorUtil.<clinit>(StackLocatorUtil.java:33)
mix-data-collector_1 | at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:133)
mix-data-collector_1 | at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:228)
mix-data-collector_1 | at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:45)
mix-data-collector_1 | at org.apache.logging.log4j.LogManager.getContext(LogManager.java:174)
mix-data-collector_1 | at org.springframework.boot.logging.log4j2.Log4J2LoggingSystem.getLoggerContext(Log4J2LoggingSystem.java:305)
mix-data-collector_1 | at org.springframework.boot.logging.log4j2.Log4J2LoggingSystem.beforeInitialize(Log4J2LoggingSystem.java:145)
mix-data-collector_1 | at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationStartingEvent(LoggingApplicationListener.java:232)
mix-data-collector_1 | at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEvent(LoggingApplicationListener.java:213)
mix-data-collector_1 | at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
mix-data-collector_1 | at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
mix-data-collector_1 | at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
mix-data-collector_1 | at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:127)
mix-data-collector_1 | at org.springframework.boot.context.event.EventPublishingRunListener.starting(EventPublishingRunListener.java:74)
mix-data-collector_1 | at org.springframework.boot.SpringApplicationRunListeners.starting(SpringApplicationRunListeners.java:47)
mix-data-collector_1 | at org.springframework.boot.SpringApplication.run(SpringApplication.java:305)
mix-data-collector_1 | at ch.sbb.esta.openshift.gracefullshutdown.GracefulshutdownSpringApplication.run(GracefulshutdownSpringApplication.java:21)
mix-data-collector_1 | at com.nuance.core.mix.data.collector.Application.main(Application.java:38)
mix-data-collector_1 | ... 8 more
mix-data-collector_1 | Caused by: java.lang.ClassNotFoundException: org.apache.logging.log4j.util.StackLocator$FqcnCallerLocator
mix-data-collector_1 | at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:471)
mix-data-collector_1 | at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:589)
mix-data-collector_1 | at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:93)
mix-data-collector_1 | at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
mix-data-collector_1 | ... 27 more
mix-data-collector_mix-data-collector_1 exited with code 1loader.Launcher.launch(Launcher.java:87)
mix-data-collector_1 | at org.springframework.boot.loader.Launcher.launch(Launcher.java:50)
mix-data-collector_1 | at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51)
mix-data-collector_1 | Caused by: java.lang.NoClassDefFoundError: org/apache/logging/log4j/util/StackLocator$FqcnCallerLocator
mix-data-collector_1 | at org.apache.logging.log4j.util.StackLocator.<clinit>(StackLocator.java:37)
mix-data-collector_1 | at org.apache.logging.log4j.util.StackLocatorUtil.<clinit>(StackLocatorUtil.java:33)
mix-data-collector_1 | at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:133)
mix-data-collector_1 | at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:228)
mix-data-collector_1 | at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:45)
mix-data-collector_1 | at org.apache.logging.log4j.LogManager.getContext(LogManager.java:174)
mix-data-collector_1 | at org.springframework.boot.logging.log4j2.Log4J2LoggingSystem.getLoggerContext(Log4J2LoggingSystem.java:305)
mix-data-collector_1 | at org.springframework.boot.logging.log4j2.Log4J2LoggingSystem.beforeInitialize(Log4J2LoggingSystem.java:145)
mix-data-collector_1 | at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationStartingEvent(LoggingApplicationListener.java:232)
mix-data-collector_1 | at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEvent(LoggingApplicationListener.java:213)
mix-data-collector_1 | at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
mix-data-collector_1 | at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
mix-data-collector_1 | at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
mix-data-collector_1 | at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:127)
mix-data-collector_1 | at org.springframework.boot.context.event.EventPublishingRunListener.starting(EventPublishingRunListener.java:74)
mix-data-collector_1 | at org.springframework.boot.SpringApplicationRunListeners.starting(SpringApplicationRunListeners.java:47)
mix-data-collector_1 | at org.springframework.boot.SpringApplication.run(SpringApplication.java:305)
mix-data-collector_1 | at ch.sbb.esta.openshift.gracefullshutdown.GracefulshutdownSpringApplication.run(GracefulshutdownSpringApplication.java:21)
mix-data-collector_1 | at com.nuance.core.mix.data.collector.Application.main(Application.java:38)
mix-data-collector_1 | ... 8 more
mix-data-collector_1 | Caused by: java.lang.ClassNotFoundException: org.apache.logging.log4j.util.StackLocator$FqcnCallerLocator
mix-data-collector_1 | at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:471)
mix-data-collector_1 | at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:589)
mix-data-collector_1 | at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:93)
mix-data-collector_1 | at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
mix-data-collector_1 | ... 27 more
mix-data-collector_mix-data-collector_1 exited with code 1
我的Maven依赖项如下所示:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>${log4j.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>${log4j.version}</version>
</dependency>
在log4j 2.11.2版本中,应用程序启动正常(所以在最新的log4j版本中有一些改变),但我需要转移到2.13.3版本,以减轻一些安全问题。
谢谢你
最新依赖项:
2条答案
按热度按时间xzabzqsa1#
好的,我已经找到我的问题了。似乎还有一个spring maven插件依赖导致了这个问题。谢谢你的帮助
csbfibhn2#
我已经通过将log4j-code依赖关系升级到2.14.1版解决了同样的问题