尝试为Spring Pet Clinic应用程序添加安全性。我通过向此项目添加两个类SecurityConfig
和Cannot initialize context because there is already a root application context present - check whether you have multiple ContextLoader* definitions in your web.xml!
来实现此目的,现在我收到此错误:
web.xml
确实在ContextLoaderListener
中提到了MessageSecurityWebApplicationInitizializer
。
AbstractSecurityWebApplicationInitializer
只是扩展ContextLoaderListener
而没有自定义。我相信这个类加载了额外的{{1}},但不知道如何防止这种情况,或者如果这样做是可取的。我尝试实现界面并执行此问题中的建议:
Why this Spring application with java-based configuration don't work properly
但这不起作用。
我想知道我是否尝试将Spring XML配置与非XML配置混合使用。但主要是我想让安全工作。