gpt4 book ai didi

java - @Profile ("String") 和 @ProfileName 有什么区别

转载 作者:行者123 更新时间:2023-11-30 02:08:16 25 4
gpt4 key购买 nike

这两个配置文件定义有什么区别。

@Profile("prod")
public DatabaseDatasource getProductionDatabase() {
//code
}

@Profile("prod")
public @interface ProdProfile{}

@ProdProfile
public DatabaseDatasource getProductionDatabase() {
//code
}

最佳答案

没有区别。

不同之处在于您只需将所需的配置文件编写为接口(interface)。如果您决定更改配置文件名称,则只需在一个位置更改它,而不是像您的示例中那样在整个项目中搜索文字“prod”。

要么不重复自己,效果应该是一样的

关于java - @Profile ("String") 和 @ProfileName 有什么区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50871958/

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