jjaros
jjaros

Reputation: 538

Grails 3.0.2 cannot resolve @Secured annotation in controller

I try upgrade my application from Grails 2.4.4 to Grails 3.0.2 and I have problem with spring annotation.

I have controller, like this:

import grails.plugins.springsecurity.annotation.Secured

class MyController {  

    @Secured(['ROLE_ADMINS_GROUP'])
    def index() {
        // some code
    }
}

In depencencies block in build.gradle I have this:

dependencies {
    provided 'org.springframework.boot:spring-boot-starter-logging'
    provided "org.springframework.boot:spring-boot-starter-actuator"
    provided "org.springframework.boot:spring-boot-autoconfigure"
    provided "org.springframework.boot:spring-boot-starter-tomcat"

    compile "org.springframework.boot:spring-boot-starter-security"

    provided "org.grails:grails-web-boot"
    provided "org.grails:grails-dependencies"
    provided 'javax.servlet:javax.servlet-api:3.1.0'

    testCompile "org.grails:grails-plugin-testing"

    console "org.grails:grails-console"

    compile "org.grails.plugins:wslite:0.7.2.0"
}

When i try compile my application, I get error message.

MyController.groovy: 4: unable to resolve class grails.plugins.springsecurity.annotation.Secured
@ line 4, column 1.
import grails.plugins.springsecurity.annotation.Secured
^

Upvotes: 3

Views: 1158

Answers (1)

jan2jen
jan2jen

Reputation: 33

Spring Security Core Plugin has already been updated and is now compatible with Grails 3.0 see the docs: What's New in Version 3.0

Just add following dependency to the dependencies block of the build.gradle file:

compile "org.grails.plugins:spring-security-core:3.0.0.M1"

Upvotes: 1

Related Questions