栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

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

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

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>

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



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/635870.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号