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

相关文章
|
7月前
|
Android开发
复杂项目即时通讯从android 5升级android x后遗症之解决报错#79 java.io.EOFException Unexpected end of ZLIB input stream-优雅草卓伊凡|bigniu
复杂项目即时通讯从android 5升级android x后遗症之解决报错#79 java.io.EOFException Unexpected end of ZLIB input stream-优雅草卓伊凡|bigniu
437 4
复杂项目即时通讯从android 5升级android x后遗症之解决报错#79 java.io.EOFException Unexpected end of ZLIB input stream-优雅草卓伊凡|bigniu
|
6月前
|
Java API 开发工具
【Azure Developer】Java代码实现获取Azure 资源的指标数据却报错 "invalid time interval input"
在使用 Java 调用虚拟机 API 获取指标数据时,因本地时区设置非 UTC,导致时间格式解析错误。解决方法是在代码中手动指定时区为 UTC,使用 `ZoneOffset.ofHours(0)` 并结合 `withOffsetSameInstant` 方法进行时区转换,从而避免因时区差异引发的时间格式问题。
321 4
|
5月前
|
JSON Java 数据格式
java调用服务报错400
java调用服务报错400
142 6
java调用服务报错400
|
5月前
|
JSON Java 数据格式
java调用服务报错415 Content type ‘application/octet-stream‘ not supported
java调用服务报错415 Content type ‘application/octet-stream‘ not supported
343 6
|
10月前
|
Java
Java 中 Exception 和 Error 的区别
在 Java 中,`Exception` 和 `Error` 都是 `Throwable` 的子类,用于表示程序运行时的异常情况。`Exception` 表示可被捕获和处理的异常,分为受检异常(Checked)和非受检异常(Unchecked),通常用于程序级别的错误处理。而 `Error` 表示严重的系统级问题,如内存不足或 JVM 错误,一般不建议捕获和处理。编写程序时应重点关注 `Exception` 的处理,确保程序稳定性。
313 0
|
Java Maven
java项目中jar启动执行日志报错:no main manifest attribute, in /www/wwwroot/snow-server/z-server.jar-jar打包的大小明显小于正常大小如何解决
在Java项目中,启动jar包时遇到“no main manifest attribute”错误,且打包大小明显偏小。常见原因包括:1) Maven配置中跳过主程序打包;2) 缺少Manifest文件或Main-Class属性。解决方案如下:
3072 8
java项目中jar启动执行日志报错:no main manifest attribute, in /www/wwwroot/snow-server/z-server.jar-jar打包的大小明显小于正常大小如何解决
|
运维 Cloud Native Java
postman发起post请求遇到报错:java.io.FileNotFoundException (文件名、目录名或卷标语法不正确。)
遇到bug报错,多猜可能的原因,控制变量反复测试,直至找到问题的关键,然后再思考如何解决或者回避。 博客不应该只有代码和解决方案,重点应该在于给出解决方案的同时分享思维模式,只有思维才能可持续地解决问题,只有思维才是真正值得学习和分享的核心要素。如果这篇博客能给您带来一点帮助,麻烦您点个赞支持一下,还可以收藏起来
|
Java Windows
【Azure Function】部署Java Function失败:报错deploy [ERROR] Status code 401和警告 'China North 3' may not be a valid region
1:deploy [ERROR] Status code 401, (empty body). 2: China North 3 may not be a valid region,please refer to https://aka.ms/maven_function_configuration#supported-regions for values. 3:  <azure.functions.maven.plugin.version>1.36.0</azure.functions.maven.plugin.version>
330 11
|
JSON Java 关系型数据库
Java更新数据库报错:Data truncation: Cannot create a JSON value from a string with CHARACTER SET 'binary'.
在Java中,使用mybatis-plus更新实体类对象到mysql,其中一个字段对应数据库中json数据类型,更新时报错:Data truncation: Cannot create a JSON value from a string with CHARACTER SET 'binary'.
1534 4
Java更新数据库报错:Data truncation: Cannot create a JSON value from a string with CHARACTER SET 'binary'.