gpt4 book ai didi

spring - Grails 3.0.2 无法解析 Controller 中的@Secured 注释

转载 作者:行者123 更新时间:2023-12-02 03:24:57 24 4
gpt4 key购买 nike

我尝试将我的应用程序从 Grails 2.4.4 升级到 Grails 3.0.2,但我遇到了 spring 注释的问题。

我有 Controller ,像这样:

import grails.plugins.springsecurity.annotation.Secured

class MyController {

@Secured(['ROLE_ADMINS_GROUP'])
def index() {
// some code
}
}

build.gradledepencencies block 中,我有这个:

dependencies {
provided 'org.springframework.boot:spring-boot-starter-logging'
provided "org.springframework.boot:spring-boot-starter-actuator"
provided "org.springframework.boot:spring-boot-autoconfigure"
provided "org.springframework.boot:spring-boot-starter-tomcat"

compile "org.springframework.boot:spring-boot-starter-security"

provided "org.grails:grails-web-boot"
provided "org.grails:grails-dependencies"
provided 'javax.servlet:javax.servlet-api:3.1.0'

testCompile "org.grails:grails-plugin-testing"

console "org.grails:grails-console"

compile "org.grails.plugins:wslite:0.7.2.0"
}

当我尝试编译我的应用程序时,我收到错误消息。

MyController.groovy: 4: unable to resolve class grails.plugins.springsecurity.annotation.Secured
@ line 4, column 1.
import grails.plugins.springsecurity.annotation.Secured
^

最佳答案

Spring Security 核心插件已经更新,现在与 Grails 3.0 兼容,请参阅文档:What's New in Version 3.0

只需将以下依赖项添加到 build.gradle 文件的 dependencies block 中:

compile "org.grails.plugins:spring-security-core:3.0.0.M1"

关于spring - Grails 3.0.2 无法解析 Controller 中的@Secured 注释,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30917788/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com