gpt4 book ai didi

grails - grails Bootstrap 错误写入mysql

转载 作者:行者123 更新时间:2023-12-02 14:52:56 25 4
gpt4 key购买 nike

我在一个简单的应用程序中使用spring security。连接到Amazon RDS实例时,该应用程序在本地运行良好。当我将应用程序上载到Elastic beantalk时,在Bootstrap中创建角色失败:

def init = { servletContext ->

println log.name

log.debug("hello 1")
def adminRole = new Role(authority: 'ROLE_ADMIN')
log.debug("hello 2")
if (!adminRole.save(flush: true, failOnError: true)) {
log.debug("hello 3")
adminRole.errors.each {
println it
log.error(it)
}
}

2013-12-17 23:25:33,311 [localhost-startStop-1] ERROR context.GrailsContextLoader - Error initializing the application: groovy.lang.MissingMethodException: No signature of method: com.nrfa.Role.save() is applicable for argument types: () values: []
Possible solutions: save(), save(boolean), save(java.util.Map), wait(), last(), any()
org.codehaus.groovy.runtime.InvokerInvocationException: groovy.lang.MissingMethodException: No signature of method: com.nrfa.Role.save() is applicable for argument types: () values: []
Possible solutions: save(), save(boolean), save(java.util.Map), wait(), last(), any()
at grails.util.Environment.evaluateEnvironmentSpecificBlock(Environment.java:308)
at grails.util.Environment.executeForEnvironment(Environment.java:301)
at grails.util.Environment.executeForCurrentEnvironment(Environment.java:277)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)
Caused by: groovy.lang.MissingMethodException: No signature of method: com.nrfa.Role.save() is applicable for argument types: () values: []
Possible solutions: save(), save(boolean), save(java.util.Map), wait(), last(), any()
at BootStrap$_closure1.doCall(BootStrap.groovy:15)
... 9 more

如果是数据库连接问题(可能是),我会认为该错误是“嘿,无法连接到数据库”。找不到Role.save()的非描述性错误。

编辑:
完整的 bootstrap :
import com.nrfa.Role
import com.nrfa.User
import com.nrfa.UserRole

class BootStrap {
def springSecurityService

def init = { servletContext ->

println log.name

log.debug("hello 1")
def adminRole = new Role(authority: 'ROLE_ADMIN')
log.debug("hello 2")
if (!adminRole.save(flush: true, failOnError: true)) {
log.debug("hello 3")
adminRole.errors.each {
println it
log.error(it)
}
}
log.debug("hello 4")
def userRole = new Role(authority: 'ROLE_USER').save(flush: true, failOnError: true)

def testUser = new User(username: 'me', password: 'password')
testUser.save(flush: true, failOnError: true)

UserRole.create testUser, userRole, true

assert User.count() == 1
assert Role.count() == 2
assert UserRole.count() == 1


}

def destroy = {
}
}

编辑:包括BuildConfig.Groovy:
dependencies {
// specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes e.g.

//runtime 'mysql:mysql-connector-java:5.1.27'

runtime 'org.slf4j:slf4j-api:1.7.5'
}

plugins {
build ":hibernate:$grailsVersion"
runtime ":jquery:1.8.3"
runtime ":resources:1.2"
runtime ":mysql-connectorj:5.1.22.1"
compile ':spring-security-core:2.0-RC2'


// Uncomment these (or add new ones) to enable additional resources capabilities
//runtime ":zipped-resources:1.0"
//runtime ":cached-resources:1.0"
//runtime ":yui-minify-resources:0.1.5"

build ":tomcat:$grailsVersion"

build ":database-migration:1.3.2"

compile ':cache:1.0.1'

//运行时“:mysql-connectorj:5.1.22.1”
}

最佳答案

该错误通常表明未安装或运行休眠插件。您能在远程服务器上看到扩大的 war 吗?我不熟悉beantalk本身的工作原理,因此那里可能存在冲突。

关于grails - grails Bootstrap 错误写入mysql,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20646838/

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