2016-08-15 297 views
1

我已經添加上的build.gradle以下春天安全dependecy添加到我的項目在應用程序啓動

compile 'org.grails.plugins:spring-security-core:3.1.1' 

但是,當我開始我的應用程序我得到下面的異常Grails的3.2.0.M2春季安全異常

ERROR org.springframework.boot.SpringApplication - Application startup failed 
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'grailsApplicationPostProcessor' defined in workspace.Application: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [grails.boot.config.GrailsApplicationPostProcessor]: Factory method 'grailsApplicationPostProcessor' threw exception; nested exception is java.lang.NoClassDefFoundError: grails/plugin/springsecurity/ControllerMixin 
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:599) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1123) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1018) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:510) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) 
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) 
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) 
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) 
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) 
    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:120) 
    at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:681) 
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:523) 
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) 
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759) 
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:369) 
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:313) 
    at grails.boot.GrailsApp.run(GrailsApp.groovy:55) 
    at grails.boot.GrailsApp.run(GrailsApp.groovy:374) 
    at grails.boot.GrailsApp.run(GrailsApp.groovy:363) 
    at grails.boot.GrailsApp$run.call(Unknown Source) 
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48) 
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113) 
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:133) 
    at workspace.Application.main(Application.groovy:8) 

我正在使用JDK 8作爲我的sdk。

回答

0

看起來像你還沒有配置插件。 您需要在您的application.yml 配置插件例如:

grails: 
    plugin: 
    springsecurity: 
     userLookup.usernamePropertyName: 'usernameProperty' 
     userLookup.userDomainClassName: 'com.yourProject.User' 
     userLookup.authorityJoinClassName: 'com.yourProject.UserRole' 
     authority.className: 'com.yourProject.Role' 
     password: 
     algorithm: bcrypt 
     encodeHashAsBase64: true 
     bcrypt.logrounds: 4 
     rejectIfNoRule: true 
     successHandler.defaultTargetUrl:/
     controllerAnnotations: 
     staticRules: 
     - pattern: '/**' 
      access: ['permitAll'] 

還需要類com.yourProject.User,com.yourProject.UserRole和com.yourProject.Role。 - http://grails-plugins.github.io/grails-spring-security-core/

grails s2-quickstart com.yourProject User Role 

在這裏你可以找到很好的文檔: 基本配置可以用Q2-快速啓動腳本來創建