spring - 在本地工作但不在生产环境中使用 UnsatisfiedDependencyException 创建名称为 'webSecurityConfiguration 的 bean

标签 spring spring-mvc tomcat spring-boot spring-security

本地应用正常,部署后报错:

Caused by: org.springframework.context.ApplicationContextException:

Unable to start embedded container; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'webSecurityConfiguration': Unsatisfied dependency expressed through field 'userDetailsService'; nested exception

上周我部署了一个旧版本的相同的应用程序并且应用程序运行正常。我该如何解决?

@Configuration
@EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled = true)
public class WebSecurityConfiguration extends WebSecurityConfigurerAdapter {

    @Autowired
    private EntryPointUnauthorizedHandler unauthorizedHandler;

    @Autowired//package org.springframework.security.core.userdetails;
    private UserDetailsService userDetailsService;

我在服务器 Apache Tomcat/7.0.68 和 java: 1.8.0_11- 上使用 spring boot 和 war 与 providedRuntime('org.springframework.boot:spring-boot-starter-tomcat' b12

最佳答案

 @Autowired//
 private UserDetailsService userDetailsService;

package org.springframework.security.core.userdetails就我而言,问题出在数据库上,代码本身是正确的,不需要更改

关于spring - 在本地工作但不在生产环境中使用 UnsatisfiedDependencyException 创建名称为 'webSecurityConfiguration 的 bean,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41077370/

相关文章:

jsp - 我可以在哪里放置上传文件夹,这样当我在 Tomcat 中部署/取消部署站点时,该文件夹不会受到影响

java - 使用spring存储过程调用oracle存储过程

java - Spring @Controller 异常处理程序和全局异常处理程序。如何调用两者

spring - 在 AbstractAuthenticationProcessingFilter 中连接服务以添加身份验证详细信息

spring - 如何将 jasperreports_extension.properties 与 Spring 框架集成

java - Tomcat - 将 war 部署到远程 tomcat 时出现 NoClassDefFoundError

java - Spring JPA 投影 findAll

spring - 此处不允许注释

spring - 我可以在域对象构造函数中调用grails服务吗?

java - 跨两个应用服务器管理 session