Grails Spring Core Security Plugin - Unable to Res

2019-02-16 13:37发布

问题:

I'm using Grails 2.2.2 and I've already installed spring-security-core-2.0-RC2, by adding the below lines in my BuildConfig.groovy file:

Under the plugins:    
compile ':spring-security-core:2.0-RC2'

Under Repositories:
mavenRepo 'http://repo.spring.io/milestone'

The plugin was installed successfully and I've created the security Domains and Controllers using s2-quickstart script.

Now, I've updated one of my controllers with the below code:

import grails.plugins.springsecurity.Secured
@Secured(['ROLE_ADMIN']) 

However when I try to run the application I get the below error:

| Error Compilation error: startup failed: C:\workspace\SW Development\Production\MyGrailsApp\safami\grails-app\controllers\safami\InfoPageAdminController.groovy: 4: unable to resolve class grails.plugins.springsecurity.Secured @ line 4, column 1. import grails.plugins.springsecurity.Secured

I'm new to Grails and I need your detailed solution.

回答1:

The annotation was moved to a different package - change

import grails.plugins.springsecurity.Secured

to

import grails.plugin.springsecurity.annotation.Secured