@ActiveProfile和spring.profiles.active [英] @ActiveProfile and spring.profiles.active

查看:7563
本文介绍了@ActiveProfile和spring.profiles.active的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的一个applicationContext定义来检索一些属性。

This is a piece of my applicationContext definition to retrieve some properties.

 <!-- get some properties -->
<context:property-placeholder
        ignore-resource-not-found="false" ignore-unresolvable="false"
        location="classpath:/properties/${spring.profiles.active:test}/some.properties"/>

正如你可以看到,我让spring.profiles.active决定读取哪些属性。
我的测试注释为:

As you can see I letting the spring.profiles.active decide which properties will be read. My tests are annotated with:

@ActiveProfile("integration")

你猜到了,我的spring bean配置文件实际上匹配了部署/测试应用程序的环境。
仍然是我的位置属性正在解析为/properties/test/some.properties。这当然是因为在这种情况下spring.profiles.active似乎没有得到解决。

You guessed it right my spring bean profiles are actually matching the environments in which to deploy/test the application. Still my location property is getting resolved to "/properties/test/some.properties". Which is of course because the spring.profiles.active doesn't seem to get resolved in this case.

如何获得正确的属性?

How could I achieve getting the the right properties?

推荐答案

查看票证: https://jira.springsource.org/browse/SPR-8982#comment-88498

有人已经发出请求:


在运行时通过-Dspring.profiles从命令行覆盖由test指定的@ActiveProfile的选项。 activeor other systemProperty

An option to override an @ActiveProfile specified by test in runtime from command line by "-Dspring.profiles.active" or other systemProperty

我的评论:


这应该设置属性spring.profiles.active。

That or it should set the property spring.profiles.active.

这篇关于@ActiveProfile和spring.profiles.active的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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