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

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

问题描述

我已经以与配置文件建议的基本相同的方式外部化了我的 Grails 配置.我一直在用我的 1.3 项目和线路完成它

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}"

在外部配置中效果很好.现在我遇到了 2.0 的问题,即 Grails 似乎无法解析 ${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?

推荐答案

您可以使用 ${grails.util.Metadata.current.getApplicationName()} 代替.

请注意,由于 Metadata 实现了 Map,您不能将其缩短为 ${grails.util.Metadata.current.applicationName},因为关键不是 applicationName.

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天全站免登陆