【问题标题】:Spring security authentication from neo4j database来自neo4j数据库的Spring安全认证
【发布时间】:2017-07-18 16:16:12
【问题描述】:

在我的 Spring MVC 应用程序中,我添加了 spring 安全性

当我尝试在登录之前从数据库中获取 AppUser 以匹配给定的用户凭据时,我收到以下错误

[http-nio-8080-exec-12] ERROR org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter - An internal error occurred while trying to authenticate the user.
org.springframework.security.authentication.InternalAuthenticationServiceException: Error creating bean with name 'scopedTarget.getSession': Scope 'session' is not active for the current thread; consider defining a scoped proxy for this bean if you intend to refer to it from a singleton; nested exception is java.lang.IllegalStateException: No thread-bound request found: Are you referring to request attributes outside of an actual web request, or processing a request outside of the originally receiving thread? If you are actually operating within a web request and still receive this message, your code is probably running outside of DispatcherServlet/DispatcherPortlet: In this case, use RequestContextListener or RequestContextFilter to expose the current request.

根据给定的建议我添加了

@ComponentScan(scopedProxy = ScopedProxyMode.INTERFACES)

到我的 UserDetailService 但仍然遇到同样的错误

我配置的数据库 url 如下

db.local.url=http://neo4j:123456@localhost:7474

如果我使用硬编码用户进行身份验证,那么我可以登录 登录后,我可以与数据库进行各种通信

但在登录之前我收到上述错误

如何解决这个问题???

我的代码要点

https://gist.github.com/sazzadislam-dsi/6a6a21216e39184e54d0c074332bb372

【问题讨论】:

    标签: spring-mvc spring-security


    【解决方案1】:

    @SpringBootApplication下方添加@EntityScan("<your package where entities are saved>")

    它适用于我的情况。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-08-25
      • 2019-03-10
      • 2020-05-10
      • 2013-02-19
      • 1970-01-01
      • 2015-04-09
      • 2016-10-21
      • 2015-03-21
      相关资源
      最近更新 更多