gpt4 book ai didi

java - Spring 环境变量

转载 作者:行者123 更新时间:2023-11-30 10:27:58 25 4
gpt4 key购买 nike

我计划对我的服务实现类使用 @Value 注释。

 @Value("${some_property:default_value}")
private String key;

要使用上面的注解,我可以使用@Autowired注解。

 @Autowird
Private Environment environment;

但是,我打算在我的 applicationContext.xml 文件中使用这些设置,如下所示。

<context: something missing here = "ENVIRONMENT"/>

最佳答案

。你可以在 applicationContext.xml beans 标签本身有一个属性叫做 profile 所以你可以做 profile="ENVIRONMENT" 在最新的 spring 版本中。

关于java - Spring 环境变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44962893/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com