gpt4 book ai didi

grails - Grails 3.0和Spring安全性错误

转载 作者:行者123 更新时间:2023-12-02 15:54:07 25 4
gpt4 key购买 nike

在我的build.gradle中,我添加了以下代码

 dependencies {

compile "org.grails.plugins:spring-security-core:3.0.3"

}

然后当我尝试使用它
    import grails.plugin.springsecurity.annotation.Secured

@Secured('ROLE_ADMIN')
class SecureController {
def index() {
render 'Secure access only'
}

它“无法解析符号springsecurity”
我得到错误
 Error:(5, 1) Groovyc: unable to resolve class Secured ,  unable to find class for annotation

任何帮助将非常感激。

enter image description here

Build.gradle ****编辑

这是整个build.gradle文件
    buildscript {
ext {
grailsVersion = project.grailsVersion
}
repositories {
mavenLocal()
maven { url "https://repo.grails.org/grails/core" }
}
dependencies {
classpath "org.grails:grails-gradle-plugin:$grailsVersion"
classpath 'com.bertramlabs.plugins:asset-pipeline-gradle:2.5.0'
classpath "org.grails.plugins:hibernate:4.3.10.5"
}
}

plugins {
id "io.spring.dependency-management" version "0.5.4.RELEASE"
}

version "0.1"
group "securityrolesspring"

apply plugin: "spring-boot"
apply plugin: "war"
apply plugin: "asset-pipeline"
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: "org.grails.grails-web"
apply plugin: "org.grails.grails-gsp"

ext {
grailsVersion = project.grailsVersion
gradleWrapperVersion = project.gradleWrapperVersion
}

assets {
minifyJs = true
minifyCss = true
}

repositories {
mavenLocal()
maven { url "https://repo.grails.org/grails/core" }

}
  dependencyManagement {
imports {
mavenBom "org.grails:grails-bom:$grailsVersion"
}
applyMavenExclusions false
}

dependencies {
compile "org.grails.plugins:spring-security-core:3.0.3"
compile "org.springframework.boot:spring-boot-starter-logging"
compile "org.springframework.boot:spring-boot-starter-actuator"
compile "org.springframework.boot:spring-boot-autoconfigure"
compile "org.springframework.boot:spring-boot-starter-tomcat"
compile "org.grails:grails-dependencies"
compile "org.grails:grails-web-boot"

compile "org.grails.plugins:hibernate"
compile "org.grails.plugins:cache"
compile "org.hibernate:hibernate-ehcache"
compile "org.grails.plugins:scaffolding"

runtime "org.grails.plugins:asset-pipeline"

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

// Note: It is recommended to update to a more robust driver (Chrome, Firefox etc.)
testRuntime 'org.seleniumhq.selenium:selenium-htmlunit-driver:2.44.0'

console "org.grails:grails-console"
}

task wrapper(type: Wrapper) {
gradleVersion = gradleWrapperVersion
}

最佳答案

在“应用插件:“ war ””之后添加一行,内容为:
应用插件:“maven”

在您的存储库部分中,在“mavenLocal()”之后添加一行,内容为:
mavenCentral()

最后的建议只是装饰性的,但我会改变你的看法:
编译“org.grails.plugins:spring-security-core:3.0.3”

并将其放在
编译“org.grails.plugins:scaffolding”行。这是一种很好的形式,可以使最初的grails依赖关系集保持与最初的'grails create-app'命令相同。该规则的异常(exception)是,如果您要用其他东西替换回日志记录,那是另一回事了。

最后,您还可以将spring-security-core依赖性更改为现已发布的3.0.4版本。

关于grails - Grails 3.0和Spring安全性错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35184795/

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