'conflict in slf4j dependency

I`m using spring boot 2.6.6 and logback and slf4j. when I run application in my local computer in IntellijA IDE using "Run configuration", application starts normally. but when I build app with goal "clean package" and then run with command line "java -jar myApp.war" the following error occures:

SLF4J: The requested version 1.7.16 by your slf4j binding is not compatible with [1.6]
SLF4J: See http://www.slf4j.org/codes.html#version_mismatch for further details.
Exception in thread "main" java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49)
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:108)
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:58)
        at org.springframework.boot.loader.WarLauncher.main(WarLauncher.java:59)
Caused by: java.lang.IllegalArgumentException: Cannot instantiate interface org.springframework.context.ApplicationListener : org.springframework.boot.context.logging.LoggingApplicationListener
        at org.springframework.boot.SpringApplication.createSpringFactoriesInstances(SpringApplication.java:456)
        at org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:438)
        at org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:431)
        at org.springframework.boot.SpringApplication.<init>(SpringApplication.java:263)
        at org.springframework.boot.SpringApplication.<init>(SpringApplication.java:241)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1312)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1301)
        at com.fanap.kidzy.vidzy.VidzyApplication.main(VidzyApplication.java:16)
        ... 8 more
Caused by: java.lang.NoSuchMethodError: org.springframework.util.Assert.isTrue(ZLjava/util/function/Supplier;)V
        at org.springframework.core.ResolvableType.forClassWithGenerics(ResolvableType.java:1088)
        at org.springframework.core.ResolvableType.forClassWithGenerics(ResolvableType.java:1074)
        at org.springframework.boot.context.properties.bind.Bindable.mapOf(Bindable.java:267)
        at org.springframework.boot.context.logging.LoggingApplicationListener.<clinit>(LoggingApplicationListener.java:98)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
        at java.lang.reflect.Constructor.newInstance(Unknown Source)
        at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:126)
        at org.springframework.boot.SpringApplication.createSpringFactoriesInstances(SpringApplication.java:452)
        ... 15 more

I analyzed the pom with "dependency analyzer" plugin but slf4j 1.7.6 or 1.6 not exists! enter image description here



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source