Grails 3 and Spring Security Plugin

╄→гoц情女王★ 提交于 2019-11-27 01:19:24

问题


I've just recently started working with Grails, and I'd like to test out the Spring Security Plugin. I'm using Grails v3.0.0RC2, and I'm finding it difficult to come across accurate documentation for it with a lot of things.

I'm looking at the Grails page for the Spring Security Plugin, located at http://grails.org/plugin/spring-security-core, and it tells me to add the following to grails-app/conf/BuildConfig

plugins {
  …
  compile ':spring-security-core:2.0-RC4'
  …
}

Now, Grails 3 has done away with the BuildConfig, and moved over to using Gradle. So I figured I could just that compile line to my "dependencies" section in build.gradle and it would work, like so:

dependencies{
  ...
  compile:":spring-security-core:2.0-RC4"
}

However, that did not work. I get the error "Could not find :spring-security-core:2.0-RC4...".

Then I figured, 'Hey, it's a plugin, let me try prefacing it with "org.grails.plugins" like I see elsewhere in the build.gradle file:

dependencies{
  ...
  compile:"org.grails.plugins:spring-security-core:2.0-RC4"
}

And still no go.

I have gotten it to compile by adding the dependency found on search.maven.org, like so:

dependencies{
  ...
  compile 'org.springframework.security:spring-security-core:4.0.0.RELEASE'
}

But I don't think thats the proper way to do, because Grails documentation says I should have access to the command

grails s2-quickstart

once the plugin is installed, which I do not when I do it using the Maven repo.

I'm sure there's a simple configuration error I'm making, as I'm very new to both Grails, Spring, and Gradle, so I appreciate any help that can be provided.


回答1:


The Spring Secuirty core plugin for Grails is not Grails 3 compatible. However, since Grails 3 is based on Spring Boot you can use the Spring Security Starter for Spring Boot instead.

This has been discussed on the Grails developers mailing list and going forward many Grails plugins will not be moved to Grails 3 and instead will be replaced by pure Spring solutions.

Update

Since this question was originally asked there has been a Spring Security plugin created for Grails 3.x. It can be found here: https://bintray.com/grails/plugins/spring-security-core/view




回答2:


The "Spring Security Starter for Spring Boot" is a good starting point, but if you want to save yourself some time trying to figure out how to get it to work with Grails, check out this helpful blog post.




回答3:


I wrote the blog post @Jamie referenced in his answer and I added a new blog post describing how to use the Gorm domain classes from Spring-Security-Core plugin from Grails 2.




回答4:


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

This is what I used and it worked for me



来源:https://stackoverflow.com/questions/29286659/grails-3-and-spring-security-plugin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!