在外部配置中访问应用程序属性($ {appName}) [英] access to application properties (${appName}) in external configuration

查看:115
本文介绍了在外部配置中访问应用程序属性($ {appName})的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经将Grails配置外部化了,基本上与配置文件建议的方式相同。
我一直在用我的1.3项目和这一行完成它。

  grails.serverURL =http: // localhost:8080 / $ {appName}

在外部配置中运行良好。现在我遇到2.0的问题,Grails似乎无法解析$ {appName} - 它将使用[:]代替重定向。



只要我将这条线移回内部配置,一切正常。



有没有办法将这个配置行移动到外部配置?我做错了什么?

解决方案

您可以使用 $ {grails.util.Metadata.current。请注意,由于元数据实现了<$ c $> getApplicationName()} > c> Map 不能缩短到 $ {grails.util.Metadata.current.applicationName} ,因为键不是 applicationName


I've externalized my Grails configuration basically the same way as the config file suggests. I've done it all the time with my 1.3 projects and the line

grails.serverURL = "http://localhost:8080/${appName}"

in the external config worked great. Now I experience the problem with 2.0 that Grails seems not to be able to resolve the ${appName} - it will use [:] instead in redirects.

As soon as I move this line back to the internal configuration, everything works fine.

Is there any way to move this configuration line to the external configuration? Am I doing something wrong?

解决方案

You can use ${grails.util.Metadata.current.getApplicationName()} instead.

Note that since Metadata implements Map you can't shorten that to ${grails.util.Metadata.current.applicationName} since the key isn't applicationName.

这篇关于在外部配置中访问应用程序属性($ {appName})的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆