我想從config.grooy屬性設置依賴版本。我發現了一個最好的方法來做到這一點:pritomkumar.blogspot。這是建議的解決方案:如何訪問BuildConfig for grails 2.3.2的配置屬性
,在 'BuildConfig.groovy' 文件中以下行
def directory = new File(getClass().protectionDomain.codeSource.location.path).parent;
def config = new ConfigSlurper(grailsSettings.grailsEnv).parse(new File(directory + File.separator + "Config.groovy").toURI().toURL())
println "| Tomcat Version (API): " + config.grails.tomcat.version;
....
plugins {
runtime ":hibernate:2.2.4"
runtime ":jquery:1.8.3"
runtime ":resources:1.2"
// 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:"+config.grails.tomcat.version
runtime ":database-migration:1.3.2"
compile ':cache:1.0.1'
}
,在 'Config.groovy中'
grails.tomcat.version = "2.2.4"
以下行
但它看起來適用於較老的grails版本,因爲我得到了這個錯誤當我嘗試刷新依賴條件:
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
script15010760392501179421923.groovy: 1: unable to resolve class com.whatever.configuration.ConfigurationFilesManager
@ line 1, column 1.
import com.whatever.configuration.ConfigurationFilesManager
^
1 error
at BuildConfig.run(BuildConfig.groovy:17)
at grails.util.BuildSettings.loadConfig(BuildSettings.groovy:1087)
at grails.util.BuildSettings.loadConfig(BuildSettings.groovy)
at grails.util.BuildSettings.loadConfig(BuildSettings.groovy:1073)
at grails.util.BuildSettings.loadConfig(BuildSettings.groovy)
at grails.util.BuildSettings$loadConfig$0.callCurrent(Unknown Source)
at grails.util.BuildSettings.loadConfig(BuildSettings.groovy:1053)
|錯誤發生錯誤加載BuildConfig:啓動失敗: script15010760392501179421923.groovy:1:無法解析類com.whatever.configuration.ConfigurationFilesManager @ 1行,第1列 進口com.whatever.configuration.ConfigurationFilesManager
任何幫助?提前致謝。