0

我把我Log4jConfig.groovygrails-app/conf/configs/

我有一个这样的例外:

...nested exception is org.codehaus.groovy.grails.exceptions.GrailsConfigurationException: Class not found loading Grails application: configs.Log4jConfig

在我的 Config.groovy 中:

def configsLocation = [Log4jConfig]
environments {
    development {
        grails.config.locations = configsLocation
    }
}

提前致谢。

4

1 回答 1

1

您需要在configs指定配置位置时指定包。像下面这样的东西会给你适当的结果:

//Config.groovy
def configsLocation = [configs.Log4jConfig]
environments {
    development {
        grails.config.locations = configsLocation
    }
}

//grails-app/conf/configs/Log4jConfig.groovy
package configs //specify the package in config as well
my.foo = 1234
my.bar = "ABCD"

//Grails Console or Unit Test or render from controller
assert 1234 == grailsApplication.config.my.foo
assert "ABCD" == grailsApplication.config.my.bar
于 2013-07-02T14:57:43.907 回答