您好我已经为我的grails / groovy应用创建了一个security-app-context.xml。它如下:
<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.0.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-3.1.xsd">
<http use-expressions="true">
<intercept-url pattern="/js/**" access="IS_AUTHENTICATED_FULLY" />
<intercept-url pattern="/css/**" access="IS_AUTHENTICATED_FULLY" />
<intercept-url pattern="/images/**" access="IS_AUTHENTICATED_FULLY" />
<intercept-url pattern="/swf/**" access="IS_AUTHENTICATED_FULLY" />
<form-login />
</http>
<authentication-manager>
<authentication-provider>
<user-service>
<user name="admin" password="password" authorities="supervisor, teller, user" />
</user-service>
</authentication-provider>
</authentication-manager>
</beans:beans>
我编辑了我的web.xml:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml
/WEB-INF/security-app-context.xml --> added this
</param-value>
</context-param>
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter>
filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
我添加了spring-security-acl-3.1.0.M2.jar,spring-security-config-3.1.0.M2.jar,spring-security-core-3.1.0.M2.jar,spring-我的lib中的security-taglibs-3.1.0.M2.jar和spring-security-web-3.1.0.M2.jar但是 我在tomcat服务器启动时收到错误
org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class org.codehaus.groovy.grails.web.context.GrailsContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.web.access.intercept.FilterSecurityInterceptor#0': Cannot create inner bean '(inner bean)' of type [org.springframework.security.web.access.expression.ExpressionBasedFilterInvocationSecurityMetadataSource] while setting bean property 'securityMetadataSource'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name '(inner bean)#5': Unsatisfied dependency expressed through constructor argument with index 0 of type [org.springframework.security.web.util.UrlMatcher]: Could not convert constructor argument value of type [java.util.LinkedHashMap] to required type [org.springframework.security.web.util.UrlMatcher]: Failed to convert value of type 'java.util.LinkedHashMap' to required type 'org.springframework.security.web.util.UrlMatcher'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [java.util.LinkedHashMap] to required type [org.springframework.security.web.util.UrlMatcher]: no matching editors or conversion strategy found
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:281)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:125)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1325)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1086)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:580)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
.........and some other exceptions
我已经安装了spring security core插件,需要在某个地方定义security-app-context.xml中的权限吗? 我不知道在哪里遗失了,我遵循了春季安全教程..
答案 0 :(得分:1)
你遵循了什么教程?使用spring-security-core插件时,不要配置任何 XML,它会处理bean注册并为您添加web.xml。
请参阅http://grails-plugins.github.com/grails-spring-security-core/docs/manual/
答案 1 :(得分:-1)
您的web.xml错误,您应该只在context-param.param-value中指定一个网址