Maven 多个SLF4J弹簧启动错误

Maven 多个SLF4J弹簧启动错误,maven,log4j,spring-boot,slf4j,jhipster,Maven,Log4j,Spring Boot,Slf4j,Jhipster,我使用jhipster创建我的项目,并尝试使用mvn安装命令创建war。war成功地创建了,但是当我尝试使用java-jar命令运行war时,得到了多个SLF4J错误。然而,该项目在eclipse中运行良好 SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/Volumes/Permanent/Workspace/sample-app/target/sample-app-0.

我使用jhipster创建我的项目,并尝试使用mvn安装命令创建war。war成功地创建了,但是当我尝试使用java-jar命令运行war时,得到了多个SLF4J错误。然而,该项目在eclipse中运行良好

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/Volumes/Permanent/Workspace/sample-app/target/sample-app-0.0.1-SNAPSHOT.war!/WEB-INF/lib/log4j-slf4j-impl-2.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/Volumes/Permanent/Workspace/sample-app/target/sample-app-0.0.1-SNAPSHOT.war!/WEB-INF/lib/logback-classic-1.1.2.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.apache.logging.slf4j.Log4jLoggerFactory]
ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console.
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:483)
    at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:53)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassCastException: org.apache.logging.slf4j.Log4jLogger cannot be cast to ch.qos.logback.classic.Logger
    at org.springframework.boot.logging.logback.LogbackLoggingSystem.getLogger(LogbackLoggingSystem.java:150)
    at org.springframework.boot.logging.logback.LogbackLoggingSystem.beforeInitialize(LogbackLoggingSystem.java:86)
    at org.springframework.boot.logging.LoggingApplicationListener.onApplicationStartedEvent(LoggingApplicationListener.java:106)
    at org.springframework.boot.logging.LoggingApplicationListener.onApplicationEvent(LoggingApplicationListener.java:98)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:151)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:128)
    at org.springframework.boot.context.event.EventPublishingRunListener.publishEvent(EventPublishingRunListener.java:100)
    at org.springframework.boot.context.event.EventPublishingRunListener.started(EventPublishingRunListener.java:54)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:278)
这是pom.xml的一部分,我曾尝试排除spring引导日志记录,但它不起作用。我不知道这是否正确

    <dependency>
        <groupId>com.mattbertolini</groupId>
        <artifactId>liquibase-slf4j</artifactId>
        <version>${liquibase-slf4j.version}</version>
    </dependency>
    <dependency>
..................

       <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-actuator</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-autoconfigure</artifactId>
            <version>${spring-boot.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-loader-tools</artifactId>
            <version>${spring-boot.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-aop</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-batch</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-log4j2</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-logging</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-mail</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-velocity</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-velocity</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <exclusions>
                <exclusion>
                    <artifactId>spring-boot-starter-logging</artifactId>
                    <groupId>org.springframework.boot</groupId>
                </exclusion>
            </exclusions>
        </dependency>
        <!-- WebSocket -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-websocket</artifactId>
        </dependency>

com.mattbertolini
液化酶-slf4j
${liquibase-slf4j.version}
..................
org.springframework.boot
弹簧靴执行器
org.springframework.boot
弹簧靴自动配置
${spring boot.version}
org.springframework.boot
spring引导加载工具
${spring boot.version}
org.springframework.boot
弹簧启动机aop
org.springframework.boot
弹簧靴起动器批次
org.springframework.boot
spring引导启动器数据jpa
org.springframework.boot
spring-boot-starter-log4j2
org.springframework.boot
spring启动程序日志记录
org.springframework.boot
春季启动邮件
org.springframework.boot
弹簧启动安全
org.springframework.boot
弹簧起动试验
测试
org.springframework.boot
弹簧启动装置
org.springframework.boot
弹簧启动速度
org.springframework.boot
弹簧启动速度
org.springframework.boot
SpringBootStarterWeb
spring启动程序日志记录
org.springframework.boot
org.springframework.boot
弹簧靴起动器网箱

当我使用mvn-devendency:tree命令检查依赖关系树时,我得到了这个结果

......................
org.snmp4j:snmp4j:jar:1.10.1:compile
[INFO] |  \- log4j:log4j:jar:1.2.17:compile
..........................
所以我把log4j的排除放在snmp4j上

        <dependency>
            <groupId>org.snmp4j</groupId>
            <artifactId>snmp4j</artifactId>
            <version>${snmp4j.version}</version>
            <exclusions>
                <exclusion>
                    <artifactId>log4j</artifactId>
                    <!-- declare the exclusion here -->
                    <groupId>log4j</groupId>
                </exclusion>
            </exclusions>
        </dependency>

org.snmp4j
snmp4j
${snmp4j.version}
log4j
log4j
它是有效的