首页 > TAG信息列表 > spring-config

java-Spring @Primary-如果主要存在,为什么要创建其他bean

我不明白@Primary可以解决什么问题. 文档说: Indicates that a bean should be given preference when multiple candidates are qualified to autowire a single-valued dependency. If exactly one ‘primary’ bean exists among the candidates, it will be the autowir

刷新Spring Boot自动配置的属性

我可以动态刷新Spring Boot自动配置设置使用的属性吗? 例如,我有以下属性设置(通过云配置)来自动配置dataSource: spring.datasource.username=user1 spring.datasource.password=test 现在,如果我更改配置服务器上的密码prop,并点击/ refresh端点,我可以看到检索到更新的prop,但不

java – 在使用@refreshScope注释的多个实例上应用/刷新

我正在编写Spring启动应用程序,它使用弹簧配置,部署在关键的云代工厂上,并由Netflix Eureka作为发现服务器/负载均衡器公开. 我创建了一个bean如下: @Component @ConfigurationProperties("config") @RefreshScope @Data public class GeneralProperties { private boolean ign

Spring Boot:具有不同前缀的多个类似ConfigurationProperties

我正在使用Spring Boot并且有两个非常相似的服务,我想在我的application.yml中配置它. 配置看起来大致如下: serviceA.url=abc.com serviceA.port=80 serviceB.url=def.com serviceB.port=8080 是否可以创建一个使用@ConfigurationProperties注释的类并在注入点设置前缀? 例如 @C