Grails 3 和 Spring 安全插件 [英] Grails 3 and Spring Security Plugin

查看:17
本文介绍了Grails 3 和 Spring 安全插件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近才开始使用 Grails,我想测试 Spring Security 插件.我使用的是 Grails v3.0.0RC2,我发现很难找到包含很多内容的准确文档.

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.

我正在查看 Spring Security 插件的 Grails 页面,位于 http://grails.org/plugin/spring-security-core,它告诉我将以下内容添加到 grails-app/conf/BuildConfig

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'
  …
}

现在,Grails 3 已经取消了 BuildConfig,转而使用 Gradle.所以我想我可以在 build.gradle 中将那条编译行添加到我的依赖项"部分,它会起作用,就像这样:

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"
}

然而,这并没有奏效.我收到错误找不到 :spring-security-core:2.0-RC4...".

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

然后我想,'嘿,这是一个插件,让我尝试用org.grails.plugins"作为前缀,就像我在 build.gradle 文件中的其他地方看到的那样:

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"
}

还是不行.

我通过添加在 search.maven.org 上找到的依赖项来编译它,如下所示:

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'
}

但我认为这不是正确的做法,因为 Grails 文档说我应该有权访问命令

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

一旦安装了插件,当我使用 Maven 存储库时我不会这样做.

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

我确定我犯了一个简单的配置错误,因为我对 Grails、Spring 和 Gradle 都很陌生,所以我很感激能提供的任何帮助.

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.

推荐答案

Grails 的 Spring Secuirty 核心插件与 Grails 3 不兼容.但是,由于 Grails 3 基于 Spring Boot,您可以使用 Spring Security Starter for Spring Boot 代替.

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.

这已经在 Grails 开发人员邮件列表中讨论,并且今后许多 Grails 插件将不会移至 Grails 3,而是由纯 Spring 解决方案取代.

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.

更新

自从最初提出这个问题以来,已经为 Grails 3.x 创建了一个 Spring Security 插件.可以在这里找到:https://bintray.com/grails/plugins/弹簧安全核心/视图

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

这篇关于Grails 3 和 Spring 安全插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆