2024-03-10 12:20:55.281 INFO 58776 --- [nio-8002-exec-2] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'
2024-03-10 12:20:55.283 INFO 58776 --- [nio-8002-exec-2] o.s.web.servlet.DispatcherServlet : Completed initialization in 2 ms
2024-03-10 12:20:55.292 DEBUG 58776 --- [nio-8002-exec-2] o.s.security.web.FilterChainProxy : Securing POST /oauth/token
2024-03-10 12:21:00.952 DEBUG 58776 --- [nio-8002-exec-2] s.s.w.c.SecurityContextPersistenceFilter : Set SecurityContextHolder to empty SecurityContext
2024-03-10 12:21:01.683 DEBUG 58776 --- [nio-8002-exec-2] s.s.w.c.SecurityContextPersistenceFilter : Cleared SecurityContextHolder to complete request
2024-03-10 12:21:01.689 ERROR 58776 --- [nio-8002-exec-2] o.a.c.c.C.[.[.[.[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [/authorization] threw exception [Filter execution threw an exception] with root cause
java.lang.StackOverflowError: null
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:344) ~[spring-aop-5.3.31.jar:5.3.31]
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:198) ~[spring-aop-5.3.31.jar:5.3.31]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) ~[spring-aop-5.3.31.jar:5.3.31]
at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:137) ~[spring-aop-5.3.31.jar:5.3.31]
at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:124) ~[spring-aop-5.3.31.jar:5.3.31]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.3.31.jar:5.3.31]
問題原因:
1.沒有加 @Qualifier("ClientDetailsServiceImpl"),走到其他ClientDetailsService實現類了,一直達不到斷點。
// 管理客戶端應用程式的資訊和憑據
@Autowired
// @Qualifier("ClientDetailsServiceImpl")
private ClientDetailsService clientDetailsService;
2. 沒有設定密碼,引數遺漏; clientDetails.setClientSecret(oauthClient.getClientSecret());
參考:https://github.com/workeritagent1/itagent1-braincells.git