Reputation: 1448
I want go get spring security authentication form. Here part of spring-security.xml file
<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>
I got error: No bean named 'customAuthenticationProvider' is defined
The beans resolution is done by Java configuration as follows:
@Configuration
@ComponentScan(basePackages = {"com.portal"})
public class MainConfiguration {
@Bean
public CustomAuthenticationProvider customAuthenticationProvider() {
return new CustomAuthenticationProvider();
}
}
Is it any problem with this configuration?
Upvotes: 0
Views: 1036
Reputation: 1448
The problem was solved by replacing
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/someXmlfile.xml</param-value>
</context-param>
with
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
com.portal.configuration.IntegrationServerWebConfig
</param-value>
</context-param>
And defining the class:
@Configuration
@ImportResource({
"classpath:/WEB-INF/mvc-dispatcher-servlet.xml",
"classpath:/WEB-INF/spring-servlet.xml"})
@ComponentScan(basePackages = {"com.portal"})
public class IntegrationServerWebConfig {
}
Upvotes: 1
Reputation: 9705
Your XML config should define which package to scan for additional components. You can do that like this:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<context:component-scan base-package="org.example"/>
</beans>
Upvotes: 0