我想在外部配置文件中定义grails.plugin.elfinder.rootDir
路径。
我在Config.groovy中使用了以下内容
grails.config.locations = [ "classpath:${appName}-config.properties",
"classpath:${appName}-config.groovy",
"file:${userHome}/docm/${appName}-config.properties",
"file:${userHome}/docm/${appName}-config.groovy"]
我已经创建了appName-config.properties文件,其中包含以下内容:
grails.plugin.elfinder.rootDir = "/home/francesco/docm_patients_doc/{patientcf}/"
我在开发和生产环境中有两个不同的问题:
开发:当加载elFinder的视图时,我有以下异常
ERROR elfinder.ElfinderConnectorController -
Error encountered while executing command elfinderOpenCommand
Message: /home/francesco/IdeaProjects/medicalOfficeManager/"/home/francesco/docm_patients_doc/sderet45t34e345t/"
Line | Method
->> 62 | getTree in
grails.plugin.elfinder.filemanager.ElfinderLocalFileSystemFileManager
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 57 | getTree in ''
| 44 | files . . in grails.plugin.elfinder.command.ElfinderBaseCommand
| 32 | execute in grails.plugin.elfinder.command.ElfinderOpenCommand
| 195 | doFilter in grails.plugin.cache.web.filter.PageFragmentCachingFilter
| 63 | doFilter in grails.plugin.cache.web.filter.AbstractFilter
| 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 615 | run in java.util.concurrent.ThreadPoolExecutor$Worker
^ 722 | run . . . in java.lang.Thread
生产。在应用程序启动时,我有以下异常
未配置grails.plugin.elfinder.rootDir
为什么我会遇到这两个不同的问题?
编辑: 按照here和here给出的示例现在我在两种情况下都有我在生产中看到的异常,即:
ERROR context.GrailsContextLoader - Error initializing the application:
grails.plugin.elfinder.rootDir is not configured
Message: grails.plugin.elfinder.rootDir is not configured
Line | Method
->> 33 | doCall in ElfinderConnectorGrailsPlugin$_closure1
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 757 | invokeBeanDefiningClosure in grails.spring.BeanBuilder
| 584 | beans . . . . . . . . . . in ''
| 527 | invokeMethod in ''
| 334 | innerRun . . . . . . . . in java.util.concurrent.FutureTask$Sync
| 166 | run in java.util.concurrent.FutureTask
| 1145 | runWorker . . . . . . . . in java.util.concurrent.ThreadPoolExecutor
| 615 | run in java.util.concurrent.ThreadPoolExecutor$Worker
^ 722 | run . . . . . . . . . . . in java.lang.Thread
编辑2:
以下是我替换占位符的方式
def replacePatientCfInConfig(String patientcf)
{
def path = grailsApplication.config.grails.plugin.elfinder.rootDir?.replace("{patientcf}", patientcf)
elfinderFileManager.root = path
return
}
这个方法被调用到我定义<div id="elfinder"></div>
的gsp页面中,就在它之前以及elfinder需要的javascript之前
我还在开发中修改了访问配置文件的方法,如下所示:
def ENV_NAME = "PROPERTIES_PATH"
if(!grails.config.location || !(grails.config.location instanceof List)) {
grails.config.location = []
}
if(System.getenv(ENV_NAME)) {
println "Including configuration file specified in environment: " + System.getenv(ENV_NAME);
grails.config.location << "file:" + System.getenv(ENV_NAME)
println(grails.config.location)
} else if(System.getProperty(ENV_NAME)) {
println "Including configuration file specified on command line: " + System.getProperty(ENV_NAME);
grails.config.location << "file:" + System.getProperty(ENV_NAME)
println(grails.config.location)
} else {
println "No external configuration file defined."
}
现在配置文件已正确加载,但我有以下异常:
ERROR context.GrailsContextLoader - Error initializing the application:
grails.plugin.elfinder.rootDir is not configured
Message: grails.plugin.elfinder.rootDir is not configured
Line | Method
->> 33 | doCall in ElfinderConnectorGrailsPlugin$_closure1
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 757 | invokeBeanDefiningClosure in grails.spring.BeanBuilder
| 584 | beans . . . . . . . . . . in ''
| 527 | invokeMethod in ''
| 334 | innerRun . . . . . . . . in java.util.concurrent.FutureTask$Sync
| 166 | run in java.util.concurrent.FutureTask
| 1145 | runWorker . . . . . . . . in java.util.concurrent.ThreadPoolExecutor
| 615 | run in java.util.concurrent.ThreadPoolExecutor$Worker
^ 722 | run . . . . . . . . . . . in java.lang.Thread
答案 0 :(得分:0)
以下适用于开发环境。
我只更改了grails.config.location
中的grails.config.locations
,并将配置文件的语法从grails.plugin.elfinder.rootDir = ...
更改为
grails{
plugin{
elfinder{
rootDir = ...}
}
}
在生产环境中,永远不会读取环境变量......为什么?