Hi!
I'm using different profiles in my webapplication for production("prod") and testing("test"). So far, everything is fine...
Now I'm trying to integrate Spring Security with the same profile approach, and I get the following error:
The configuration of Spring Security is not the problem, because EVERYTHING works fine, if I remove all @Profile or <beans profile="..."> code from my application, and I can't figure out why the problem occurs...Code:org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'springSecurityFilterChain' is defined ...
Here's my configuration code:
And at last, the relevant part in my web.xml:Code:@Profile({ "prod", "test" }) @Configuration @ImportResource("classpath:spring/security-context.xml") @ComponentScan(basePackages = { "PACKAGES_FOR_SECURITY" }) public class SecurityConfig { } @Profile({ "prod", "test" }) @Configuration @ComponentScan(basePackages = { "PACKAGES_FOR_SERVICES" }) public class ApplicationConfig { } @Profile({ "prod", "test" }) @Configuration @EnableWebMvc @ComponentScan(basePackages = { "PACKAGES_FOR_CONTROLLER" }) public class WebConfig extends WebMvcConfigurerAdapter { }
Anyone who has an idea, because I really need the separation of different profiles!Code:<context-param> <param-name>contextClass</param-name> <param-value>org.springframework.web.context.support.AnnotationConfigWebApplicationContext</param-value> </context-param> <context-param> <param-name>contextConfigLocation</param-name> <param-value>MY_CONFIG_PACKAGE</param-value> </context-param> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <filter> <filter-name>securityFilter</filter-name> <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class> <init-param> <param-name>targetBeanName</param-name> <param-value>springSecurityFilterChain</param-value> </init-param> </filter> <filter-mapping> <filter-name>securityFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <servlet> <servlet-name>appServlet</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value></param-value> </init-param> <init-param> <param-name>spring.profiles.active</param-name> <param-value>prod</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet>
Thanks a lot for any kind of help!
Markus


Reply With Quote