Java Spring安全错误:没有名为“的bean”;springSecurityFilterChain“;

Java Spring安全错误:没有名为“的bean”;springSecurityFilterChain“;,java,spring,spring-mvc,web,spring-security,Java,Spring,Spring Mvc,Web,Spring Security,我正在从事一个项目,试图实现Spring安全性,但我有一个错误,因为我将过滤器和过滤器映射放在web.xml中。我目前正在学习一个教程,视频中的人和我遵循相同的步骤,没有出现任何错误,但我做到了。所以我很困惑。有人能帮我一点忙吗 我也附上我的代码。 这是我在web.xml中的内容: <filter> <filter-name>springSecurityFilterChain</filter-name> <filter-c

我正在从事一个项目,试图实现Spring安全性,但我有一个错误,因为我将过滤器和过滤器映射放在web.xml中。我目前正在学习一个教程,视频中的人和我遵循相同的步骤,没有出现任何错误,但我做到了。所以我很困惑。有人能帮我一点忙吗

我也附上我的代码。 这是我在web.xml中的内容:

<filter>
        <filter-name>springSecurityFilterChain</filter-name>
        <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
 
<filter-mapping>
        <filter-name>springSecurityFilterChain</filter-name>
        <url-pattern>/*</url-pattern>
</filter-mapping> 
虽然不多,但我想让它工作起来,当我调用localhost:8080/login以显示默认登录表单时。
非常感谢。

您能提供服务器启动的控制台输出吗?看起来这个bean没有被加载到上下文中。老实说,它相当广泛,我不能全部粘贴在这里,问题是我读到了一些关于使用类似的东西的内容:org.springframework.web.context.ContextLoaderListener,但它不起作用,它给了我另一个错误
import org.springframework.context.annotation.Bean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;

@Configuration
@EnableWebSecurity
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {

    @Autowired
    public void configureGlobalSecurity(AuthenticationManagerBuilder auth)
            throws Exception {
        auth.inMemoryAuthentication().withUser("Checu").password("dummy")
                .roles("USER", "ADMIN");
    }

    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http.authorizeRequests().antMatchers("/login").permitAll()
                .antMatchers("/", "/*todo*/**").access("hasRole('USER')").and()
                .formLogin();
    }
}