gpt4 book ai didi

java - Spring security 未定义名为 'CustomAuthenticationProvider' 的 bean

转载 作者:行者123 更新时间:2023-12-01 13:19:56 24 4
gpt4 key购买 nike

我想要获取 Spring Security 身份验证表单。这是 spring-security.xml 文件的一部分

<bean id="authenticationFilter" class="com.portal.framework.web.security.CustomAuthenticationFilter">
<property name="authenticationManager" ref="authenticationManager" />
<property name="filterProcessesUrl" value="/login/validate" />
<property name="usernameParameter" value="usernameOrEmail" />
<property name="passwordParameter" value="password" />
<property name="authenticationSuccessHandler" ref="restAuthenticationSuccessHandler" />
<property name="authenticationFailureHandler" ref="restAuthenticationFailureHandler" />

</bean>

<authentication-manager alias="authenticationManager" xmlns="http://www.springframework.org/schema/security">
<authentication-provider ref="customAuthenticationProvider" />
</authentication-manager>

我收到错误:未定义名为“customAuthenticationProvider”的 bean

bean 解析是通过 Java 配置完成的,如下所示:

@Configuration
@ComponentScan(basePackages = {"com.portal"})
public class MainConfiguration {

@Bean
public CustomAuthenticationProvider customAuthenticationProvider() {
return new CustomAuthenticationProvider();
}
}

这个配置有问题吗?

最佳答案

更换后问题已解决

<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/someXmlfile.xml</param-value>
</context-param>

<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
com.portal.configuration.IntegrationServerWebConfig
</param-value>
</context-param>

并定义类:

@Configuration

@ImportResource({
"classpath:/WEB-INF/mvc-dispatcher-servlet.xml",
"classpath:/WEB-INF/spring-servlet.xml"})

@ComponentScan(basePackages = {"com.portal"})
public class IntegrationServerWebConfig {
}

关于java - Spring security 未定义名为 'CustomAuthenticationProvider' 的 bean,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22127344/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com