Spring sqcurity的新功能,我正在使用maven进行Spring安全性并且使用错误的错误进行混搭,我认为我打破了编译规则或其他东西,没有编译时异常。我有错误的xml配置,但无法找到它。这是我的 dispatcherservlet.xml 。
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd">
<context:component-scan base-package="com.mysecurity.springsecurity" />
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix">
<value>/WEB-INF/pages/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>
弹簧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.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security.xsd">
<http auto-config="true">
<intercept-url pattern="/admin**" access="ROLE_USER" />
</http>
<authentication-manager>
<authentication-provider>
<user-service>
<user name="admin" password="admin" authorities="ROLE_USER" />
</user-service>
</authentication-provider>
</authentication-manager>
的web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
<display-name>Spring Secured Application</display-name>
<servlet>
<servlet-name>mvc-dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>mvc-dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- Loads Spring Security config file -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/spring-security.xml
</param-value>
</context-param>
<!-- 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>
Tomcat服务器日志
`SEVERE: The required Server component failed to start so Tomcat is unable to start.
org.apache.catalina.LifecycleException: Failed to start component [StandardServer[8005]]
at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:162)
at org.apache.catalina.startup.Catalina.start(Catalina.java:629)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:351)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:485)
Caused by: org.apache.catalina.LifecycleException: Failed to start
component [StandardService[Catalina]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:162)
at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:789)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
... 7 more
引起:org.apache.catalina.LifecycleException:无法启动组件[StandardEngine [Catalina]] 在org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:162) at org.apache.catalina.core.StandardService.startInternal(StandardService.java:441) 在org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145) ......还有9个 引起:org.apache.catalina.LifecycleException:子容器在启动期间失败 在org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:951) 在org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262) 在org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145) ......还有11个 2017年6月15日下午7:14:49 org.apache.coyote.AbstractProtocol暂停 信息:暂停ProtocolHandler [&#34; http-nio-8080&#34;] 2017年6月15日下午7:14:49 org.apache.coyote.AbstractProtocol暂停 信息:暂停ProtocolHandler [&#34; ajp-nio-8009&#34;] 2017年6月15日下午7:14:49 org.apache.catalina.core.StandardService stopInternal 信息:停止服务Catalina 2017年6月15日下午7:14:49 org.apache.coyote.AbstractProtocol销毁 信息:销毁ProtocolHandler [&#34; http-nio-8080&#34;] 2017年6月15日下午7:14:49 org.apache.coyote.AbstractProtocol销毁 严重:无法销毁与之关联的终点 ProtocolHandler [&#34; http-nio-8080&#34;] org.apache.tomcat.util.net.NioEndpoint.releaseCaches中的java.lang.NullPointerException(NioEndpoint.java:315) 在org.apache.tomcat.util.net.NioEndpoint.unbind(NioEndpoint.java:491) 在org.apache.tomcat.util.net.AbstractEndpoint.destroy(AbstractEndpoint.java:883) 在org.apache.coyote.AbstractProtocol.destroy(AbstractProtocol.java:551) 在org.apache.catalina.connector.Connector.destroyInternal(Connector.java:1023) 在org.apache.catalina.util.LifecycleBase.destroy(LifecycleBase.java:292) at org.apache.catalina.core.StandardService.destroyInternal(StandardService.java:589) 在org.apache.catalina.util.LifecycleBase.destroy(LifecycleBase.java:292) 在org.apache.catalina.core.StandardServer.destroyInternal(StandardServer.java:879) 在org.apache.catalina.util.LifecycleBase.destroy(LifecycleBase.java:292) 在org.apache.catalina.startup.Catalina.start(Catalina.java:633) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) 在org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:351) 在org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:485)