0

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.

Alex Titov
  • 91
  • 1
  • 2
  • 9
  • Can you please add what error you are getting? – Abhinandan Satpute Sep 22 '16 at 18:07
  • Can you please change your plugin to `compile 'org.grails.plugins:spring-security-core:3.1.1'` and compile it once added. – Prakash Thete Sep 22 '16 at 18:40
  • Yes it works !!! //compile 'org.grails.plugins:spring-security-core:3.0.3' compile 'org.grails.plugins:spring-security-core:3.1.1' } but "import grails.plugin.springsecurity.annotation.Secured" has red underline ))) System NetBeans hint message: unable to resolve class grails.plugin.springsecurity.annotation.Secured – Alex Titov Sep 22 '16 at 18:57
  • @AlexTitov If my answer has solved your issue then you can accept it by clicking the green tick on the left side of it. – Prakash Thete Sep 28 '16 at 16:45

2 Answers2

0

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

Alex Titov
  • 91
  • 1
  • 2
  • 9
0

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.

Prakash Thete
  • 3,802
  • 28
  • 28