我想在外部配置文件中定义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未配置
为什么我有两个不同的问题?
编辑:按照此处和此处给出的示例,现在我在两种情况下都有我在生产中看到的例外,也就是说:
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
以下针对开发环境的工作。我只更改了grails.config.locations
中的grails.config.location
,然后将配置文件的语法从grails.plugin.elfinder.rootDir = ...
更改为
grails{
plugin{
elfinder{
rootDir = ...}
}
}
在生产环境中,环境变量永远不会读...为什么?