Springboot+dubbo+zookeeper 启动出错 If you are using WebLogic you will need to add ‘org.slf4j‘ to prefer

Exception in thread "restartedMain" 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.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)
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 file:/G:/apache-maven-3.5.3/repository/org/slf4j/slf4j-log4j12/1.7.30/slf4j-log4j12-1.7.30.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:696)
	at org.springframework.util.Assert.isInstanceOf(Assert.java:596)
	at org.springframework.boot.logging.logback.LogbackLoggingSystem.getLoggerContext(LogbackLoggingSystem.java:281)
	at org.springframework.boot.logging.logback.LogbackLoggingSystem.beforeInitialize(LogbackLoggingSystem.java:104)
	at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationStartingEvent(LoggingApplicationListener.java:239)
	at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEvent(LoggingApplicationListener.java:220)
	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:70)
	at org.springframework.boot.SpringApplicationRunListeners.starting(SpringApplicationRunListeners.java:47)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:305)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215)
	at gufy.mall.service.ServiceApplication.main(ServiceApplication.java:17)
	... 5 more

这个是因为zookeeper 的api使用的日志是logback,而我使用的是 slf4j 所以冲突了

这个是我的依赖

       
        
            org.apache.dubbo
            dubbo-spring-boot-starter
            2.7.7
        
        
        
            org.apache.zookeeper
            zookeeper
            3.6.1
        
        
        
            org.slf4j
            slf4j-api
            1.7.30
        

没有添加zookeeper依赖之前程序是能够起来的,后来发现是依赖冲突就把zookeeper日志依赖给屏蔽掉就行了

修改后的依赖

       
        
            org.apache.dubbo
            dubbo-spring-boot-starter
            2.7.7
        
        
        
            org.apache.zookeeper
            zookeeper
            3.6.1
            
                
                    org.slf4j
                    slf4j-log4j12
                
            
        
        
        
            org.slf4j
            slf4j-api
            1.7.30
        

 

你可能感兴趣的:(学习杂记)