小编典典

Spring Security不推荐使用@AuthenticationPrincipal

spring-mvc

如您所知,web.bind.annotation.AuthenticationPrincipal中的@AuthenticationPrincipal已弃用。建议使用core.annotation.AuthenticationPrincipal。因此,我们将import语句更改为core.annotation.AuthenticationPrincipal,现在我们得到以下错误:

org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.xxx.xxx.authentication.OurUserDetailsImpl]: No default constructor found; nested exception is java.lang.NoSuchMethodException: com.xxx.xxx.authentication.OurUserDetailsImpl.<init>()

这个注解有任何已知的问题吗?PS,我们正在使用参数化构造函数,但我们没有默认的构造函数,因此我知道这一点。非常感谢。


阅读 4759

收藏
2020-06-01

共1个答案

小编典典

请确保您使用org.springframework.security.web.method.annotation.AuthenticationPrincipalArgum‌​entResolver的并列来org.springframework.security.web.bind.support.AuthenticationPrincipalArgum‌​entResolver

*我创建了 #3771的 *UPDATE 来进行跟踪,以使其在文档中更易于遵循。

2020-06-01