grails.plugin.springsecurity.annotation problem - secured plugin is not resolving

676 Views Asked by At

I used grails 3.1.X in NetBeans 8.1. Secured plugin is not resolving wen a used annotation. Code below:

package securityplugintest
//import grails.plugins.springsecurity.Secured
import grails.plugin.springsecurity.annotation.Secured //not esolved 

@Secured(['ROLE_USER'])   //not resolved 
class ProductAnnouncementController {


 def index() {
  def announcements = ProductAnnouncement.createCriteria().list {
        order("dateCreated", "desc")
        maxResults(1)
    }
    render announcements.first()?.message
    //render announcements.any()?.meassage
    
  }
}

In NetBeans I have configured Grails 3.1.11, and spring-security plugin as

dependencies {
 compile 'org.grails.plugins:spring-security-core:3.0.3'
}

I am following this manual and getting error for the last step.

2

There are 2 best solutions below

0
Prakash Thete On BEST ANSWER

Well First thing you should add plugin compile 'org.grails.plugins:spring-security-core:3.1.1 under the build.gradle . I have just given you the different plugin version than that of you are using nothing more.

Second thing you should compile your project after adding the plugin.

This should do the trick for you.

But as you have stated that you are getting the red line under the import grails.plugin.springsecurity.annotation.Secured after above steps.

Please follow the below step :

As stated in the Grails 3 docs ->

To use annotations, specify securityConfigType="Annotation" , or leave it unspecified because it’s the default:

Specifying securityConfigType as “Annotation” grails.plugin.springsecurity.securityConfigType = "Annotation"

In your case please try to specify it.

And before running the app please clean -> compile -> run your app.

0
Alex Titov On

Can you please change your plugin to compile 'org.grails.plugins:spring-security-core:3.1.1' and compile it once added. – Prakash Thete