How to implement Spring Security 4 with both XML and Java config

前端 未结 3 603
无人共我
无人共我 2021-01-02 22:15

I am trying to implement Spring-Security 4 into my Spring MVC web and rest app. I added 2 classes to enable Spring Security the java config way. I still want to hold onto

3条回答
  •  旧时难觅i
    2021-01-02 22:50

    Assuming what you want is to get Spring Security Java Config working with only 2 classes SecurityConfig and SecurityWebApplicationInitializer, you need to do the following to get it working. Please note that I am assuming that your spring mvc configuration is still XML. Please note that com.mkyong.web.config package will have the SecurityConfigclass. This will ensure that the web context will have your security configuration available.

    Web.xml as follows

    
              contextClass
              
                  org.springframework.web.context.support.AnnotationConfigWebApplicationContext
              
          
          
              contextConfigLocation
              com.mkyong.web.config
          
    
       
          org.springframework.web.context.ContextLoaderListener
      
    

提交回复
热议问题