【问题标题】:Unable to import Spring Security @Secured Annotation into Grails 3无法将 Spring Security @Secured Annotation 导入 Grails 3
【发布时间】:2015-12-10 12:10:06
【问题描述】:

我目前正在关注 Grails here 的 Spring Security 3.0.0.M1 插件教程,我似乎被困在第 8 步。使用语句 import grails.plugin.springsecurity.annotation.Secured 不起作用,因为 Grails 无法解析包名称。我知道 Grails 3 的 Spring Security 还处于起步阶段,但是有没有人能够通过这一步呢?作为参考,这是我的 SecureController 类(另一个导入也不起作用):

package ldaptest.controllers

import grails.plugin.springsecurity.annotation.Secured;
import org.springframework.security.access.annotation.Secured;

@Secured('ROLE_ADMIN')
class SecureController {

    def index() {
        render 'Secure access only'
    }
}

【问题讨论】:

  • 目前你有 2 个进口,这两种方式都行不通。
  • 我知道。我保留了两者以防它激励某人帮助找到答案。
  • 我也遇到了同样的问题。 Intellij 15 与 Grails 3.0.9 和 Gradle。我的怀疑是,我的插件可能没有下载。为什么 SpringsSecurity 是第一个被调用的插件,它似乎只对 SpringSecurity 失败?当我使用 gradle 检查依赖项时,一切似乎都很好。

标签: spring grails spring-security spring-annotations


【解决方案1】:

我可能会找到解决方案:

  1. 创建一个“lib”文件夹,例如在“grails-app”目录中。

  2. here 下载 SpringSecurityCore JAR 并将其移至 lib 目录

  3. 添加gradle依赖:

    编译文件('lib/spring-security-core-3.0.0.M1.jar')

希望这会有所帮助。 问候

【讨论】:

  • 嗨,Mexx。感谢您的建议,但自从插件迁移到 Bintray 上的 Grails 3 后,似乎导入工作现在
【解决方案2】:

我的应用程序存在:3,1,1 保存问题。我通过将其作为库添加到我的项目来解决它。但是我必须更改导入包才能使其正常工作。

import org.springframework.security.access.annotation.Secured

我正在使用 IntelliJ IDEA,我只需要在 maven 存储库中搜索 spring-security-core:3.1.1。 在 IntelliJ 中,您执行以下操作:文件 > 项目结构 > 库 > 添加 > 从 Maven 存储库。然后根据你要使用的“spring-security-core”的版本进行搜索。

【讨论】:

    猜你喜欢
    • 2012-01-12
    • 2011-02-19
    • 2014-01-30
    • 1970-01-01
    • 2011-01-23
    • 2015-05-30
    • 2023-03-24
    • 2019-02-25
    • 1970-01-01
    相关资源
    最近更新 更多