SprinBoot项目启动报错Exception in thread “main“ java.lang.reflect.InvocationTargetException

简介: SprinBoot项目启动报错Exception in thread “main“ java.lang.reflect.InvocationTargetException

加粗的那两行就是多次引用了StaticLoggerBinder.class导致的冲突,解决办法点进入pom文件是否有重复的

我是这么解决的

<dependency>

   <groupId>com.github.binarywang</groupId>

   <artifactId>weixin-java-pay</artifactId>

   <exclusions>

       <exclusion>

           <groupId>org.slf4j</groupId>

           <artifactId>slf4j-simple</artifactId>

       </exclusion>

   </exclusions>

</dependency>

lottery-api-start........

SLF4J: Class path contains multiple SLF4J bindings.

SLF4J: Found binding in [jar:file:/data/javaprogram/lottery_api/lottery_api.war!/WEB-INF/lib/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/data/javaprogram/lottery_api/lottery_api.war!/WEB-INF/lib/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.Log4jLoggerFactory]

Exception in thread "main" java.lang.reflect.InvocationTargetException

       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

       at java.lang.reflect.Method.invoke(Method.java:498)

       at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48)

       at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)

       at org.springframework.boot.loader.Launcher.launch(Launcher.java:50)

       at org.springframework.boot.loader.WarLauncher.main(WarLauncher.java:58)

Caused by: 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.Log4jLoggerFactory loaded from jar:file:/data/javaprogram/lottery_api/lottery_api.war!/WEB-INF/lib/slf4j-log4j12-1.7.25.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.Log4jLoggerFactory

       at org.springframework.util.Assert.instanceCheckFailed(Assert.java:637)

       at org.springframework.util.Assert.isInstanceOf(Assert.java:537)

       at org.springframework.boot.logging.logback.LogbackLoggingSystem.getLoggerContext(LogbackLoggingSystem.java:274)

       at org.springframework.boot.logging.logback.LogbackLoggingSystem.beforeInitialize(LogbackLoggingSystem.java:99)

       at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationStartingEvent(LoggingApplicationListener.java:191)

       at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEvent(LoggingApplicationListener.java:170)

       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:68)

       at org.springframework.boot.SpringApplicationRunListeners.starting(SpringApplicationRunListeners.java:48)

       at org.springframework.boot.SpringApplication.run(SpringApplication.java:313)

       at org.springframework.boot.SpringApplication.run(SpringApplication.java:1255)

       at org.springframework.boot.SpringApplication.run(SpringApplication.java:1243)

       at com.zhibo.api.App.main(App.java:10)

       ... 8 more

相关文章
|
30天前
Exception in thread “main“ java.lang.NoClassDefFoundError: freemarker/template/Configuration
Exception in thread “main“ java.lang.NoClassDefFoundError: freemarker/template/Configuration
21 0
|
1月前
Exception in thread “main“ java.lang.UnsupportedOperationException
Exception in thread “main“ java.lang.UnsupportedOperationException
17 1
|
6月前
解决java.lang.Exception:No runnable methods问题~
解决java.lang.Exception:No runnable methods问题~
|
3月前
|
JSON 关系型数据库 MySQL
报错:Exception in thread "main" java.lang.UnsupportedOperationException
【1月更文挑战第19天】【1月更文挑战第94篇】报错:Exception in thread "main" java.lang.UnsupportedOperationException
43 1
|
4月前
in thread “main“ java.lang.IllegalArgumentException:java.net.UnknownHostException:hadoop102
in thread “main“ java.lang.IllegalArgumentException:java.net.UnknownHostException:hadoop102
24 0
|
8月前
|
缓存 NoSQL Redis
java.io.IOException: java.lang.RuntimeException: unable to find class for code 253
原因: 跟踪了一下所调用的底层接口,发现是redis缓存的问题,登录redis,刷新redis
45 0
|
9月前
|
Java 测试技术
已解决 java.lang.Exception: No runnable methods 异常
已解决 java.lang.Exception: No runnable methods 异常
109 0
|
Java 测试技术
Cannot instantiate test(s): java.lang.SecurityException: Prohibited package name: java
Cannot instantiate test(s): java.lang.SecurityException: Prohibited package name: java
Cannot instantiate test(s): java.lang.SecurityException: Prohibited package name: java
|
Java 关系型数据库 MySQL
Caused by: java.lang.ClassNotFoundException: com.mchange.v2.log.MLog
Caused by: java.lang.ClassNotFoundException: com.mchange.v2.log.MLog
263 0
|
SQL HIVE
Exception in thread “main“ java.lang.RuntimeException: java.lang.RuntimeException: The root scratch
Exception in thread “main“ java.lang.RuntimeException: java.lang.RuntimeException: The root scratch
195 0
Exception in thread “main“ java.lang.RuntimeException: java.lang.RuntimeException: The root scratch