Spring安全配置:IllegalStateException:BeanFactory未初始化或已关闭

Spring安全配置:IllegalStateException:BeanFactory未初始化或已关闭,第1张

Spring安全配置:IllegalStateException:BeanFactory未初始化或已关闭

看来我终于设法使它起作用了。老实说,我不知道为什么以前没用,但知道了。我认为XML标头安全性配置文件有些不好。无论如何,我已经更改了整个文件,以具有简化但有效的应用程序版本。我将发布代码:

Web.xml

<?xml version="1.0" encoding="UTF-8"?><web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">    <context-param>        <param-name>contextConfigLocation</param-name>        <param-value> /WEB-INF/applicationContext.xml /WEB-INF/applicationContext-security.xml        </param-value>    </context-param>    <listener>        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>    </listener>    <servlet>        <servlet-name>dispatcher</servlet-name>        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>        <load-on-startup>1</load-on-startup>    </servlet>    <servlet-mapping>        <servlet-name>dispatcher</servlet-name>        <url-pattern>/</url-pattern>    </servlet-mapping>    <context-param>        <param-name>log4jConfigLocation</param-name>        <param-value>/WEB-INF/log4j.properties</param-value>    </context-param>    <listener>        <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>    </listener>    <session-config>        <session-timeout> 1        </session-timeout>    </session-config>    <welcome-file-list>        <welcome-file>redirect.jsp</welcome-file>    </welcome-file-list>    <!-- Spring Security -->    <filter>        <filter-name>springSecurityFilterChain</filter-name>        <filter-class> org.springframework.web.filter.DelegatingFilterProxy        </filter-class>    </filter>    <filter-mapping>        <filter-name>springSecurityFilterChain</filter-name>        <url-pattern>/*</url-pattern>    </filter-mapping></web-app>

applicationContext-security.xml

<?xml version="1.0" encoding="UTF-8"?><beans:beans xmlns="http://www.springframework.org/schema/security"   xmlns:beans="http://www.springframework.org/schema/beans"   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd        http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd">    <http auto-config='true'>        <intercept-url pattern="/**" access="ROLE_USER" />    </http>    <authentication-manager>        <authentication-provider> <user-service>     <user name="jimi" password="jimispassword" authorities="ROLE_USER, ROLE_ADMIN" />     <user name="bob" password="bobspassword" authorities="ROLE_USER" /> </user-service>        </authentication-provider>    </authentication-manager></beans:beans>

其他文件仍然像以前一样。



欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5641734.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-16
下一篇 2022-12-16

发表评论

登录后才能评论

评论列表(0条)

保存