Oauth2認(rèn)證服務(wù)SSO錯誤

老大讓我在oauth認(rèn)證后各個微服務(wù)拿到用戶信息,所以要實現(xiàn)單點登錄,所以我在啟動類上加上了一個@EnableOAuth2Sso注解實現(xiàn)單點登錄,在idea上編譯運行都沒有錯誤,但是在服務(wù)器上部署的時候就報了一下的錯誤:

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.

2018-09-26 07:34:09.570 ERROR 1 --- [? ? ? ? ? main] o.s.boot.SpringApplication? ? ? ? ? ? ? : Application run failed

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration': Injection of autowired dependencies failed; nested exception is java.lang.IllegalStateException: @Order on WebSecurityConfigurers must be unique. Order of 100 was already used on cn.csdb.commons.oauth.config.WebSecurityConfig$$EnhancerBySpringCGLIB$$e1d4f716@ce5a68e, so it cannot be used on org.springframework.boot.autoconfigure.security.oauth2.client.OAuth2SsoDefaultConfiguration$$EnhancerBySpringCGLIB$$56419869@4fd4cae3 too.

? ? ? ? at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:378) ~[spring-beans-5.0.9.RELEASE.jar!/:5.0.9.RELEASE]

? ? ? ? at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1341) ~[spring-beans-5.0.9.RELEASE.jar!/:5.0.9.RELEASE]

? ? ? ? at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:572) ~[spring-beans-5.0.9.RELEASE.jar!/:5.0.9.RELEASE]

? ? ? ? at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:495) ~[spring-beans-5.0.9.RELEASE.jar!/:5.0.9.RELEASE]

? ? ? ? at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317) ~[spring-beans-5.0.9.RELEASE.jar!/:5.0.9.RELEASE]

? ? ? ? at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.0.9.RELEASE.jar!/:5.0.9.RELEASE]

? ? ? ? at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315) ~[spring-beans-5.0.9.RELEASE.jar!/:5.0.9.RELEASE]

? ? ? ? at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.0.9.RELEASE.jar!/:5.0.9.RELEASE]

? ? ? ? at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:759) ~[spring-beans-5.0.9.RELEASE.jar!/:5.0.9.RELEASE]

? ? ? ? at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:869) ~[spring-context-5.0.9.RELEASE.jar!/:5.0.9.RELEASE]

? ? ? ? at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550) ~[spring-context-5.0.9.RELEASE.jar!/:5.0.9.RELEASE]

? ? ? ? at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140) ~[spring-boot-2.0.5.RELEASE.jar!/:2.0.5.RELEASE]

? ? ? ? at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:780) [spring-boot-2.0.5.RELEASE.jar!/:2.0.5.RELEASE]

? ? ? ? at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:412) [spring-boot-2.0.5.RELEASE.jar!/:2.0.5.RELEASE]

? ? ? ? at org.springframework.boot.SpringApplication.run(SpringApplication.java:333) [spring-boot-2.0.5.RELEASE.jar!/:2.0.5.RELEASE]

? ? ? ? at org.springframework.boot.SpringApplication.run(SpringApplication.java:1277) [spring-boot-2.0.5.RELEASE.jar!/:2.0.5.RELEASE]

? ? ? ? at org.springframework.boot.SpringApplication.run(SpringApplication.java:1265) [spring-boot-2.0.5.RELEASE.jar!/:2.0.5.RELEASE]

? ? ? ? at cn.csdb.commons.oauth.OAuth2ServerApplication.main(OAuth2ServerApplication.java:20) [classes!/:1.0.0]

? ? ? ? at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_171]

? ? ? ? at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_171]

? ? ? ? at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_171]

? ? ? ? at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_171]

? ? ? ? at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) [app.jar:1.0.0]

? ? ? ? at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) [app.jar:1.0.0]

? ? ? ? at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) [app.jar:1.0.0]

? ? ? ? at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51) [app.jar:1.0.0]

Caused by: java.lang.IllegalStateException: @Order on WebSecurityConfigurers must be unique. Order of 100 was already used on cn.csdb.commons.oauth.config.WebSecurityConfig$$EnhancerBySpringCGLIB$$e1d4f716@ce5a68e, so it cannot be used on org.springframework.boot.autoconfigure.security.oauth2.client.OAuth2SsoDefaultConfiguration$$EnhancerBySpringCGLIB$$56419869@4fd4cae3 too.

? ? ? ? at org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration.setFilterChainProxySecurityConfigurer(WebSecurityConfiguration.java:148) ~[spring-security-config-5.0.8.RELEASE.jar!/:5.0.8.RELEASE]

? ? ? ? at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_171]

? ? ? ? at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_171]

? ? ? ? at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_171]

? ? ? ? at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_171]

? ? ? ? at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.inject(AutowiredAnnotationBeanPostProcessor.java:698) ~[spring-beans-5.0.9.RELEASE.jar!/:5.0.9.RELEASE]

? ? ? ? at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:90) ~[spring-beans-5.0.9.RELEASE.jar!/:5.0.9.RELEASE]

? ? ? ? at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:372) ~[spring-beans-5.0.9.RELEASE.jar!/:5.0.9.RELEASE]

? ? ? ? ... 25 common frames omitted

解決方法:原因就是我在啟動類上加上了一個這個注解@EnableOAuth2Sso將這個注解刪除后服務(wù)器不報錯了但是后來單點登錄就不能實現(xiàn)了,以前的單點登錄沒有測試過也,在想新的方法進(jìn)行單點登錄的實現(xiàn)......如果后期實現(xiàn)了單點登錄繼續(xù)更新

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

友情鏈接更多精彩內(nèi)容