我正在自定义 Spring Starter 项目中使用以下类和配置创建 Maven 工件:
@ConfigurationProperties(prefix = "commons.time.formats")
@Getter
@Setter
public class TimeFormatConf {
... fields
}
Run Code Online (Sandbox Code Playgroud)
@Component
@Configuration
@AllArgsConstructor
@EnableConfigurationProperties(TimeFormatConf.class)
@AutoConfigureOrder(Ordered.HIGHEST_PRECEDENCE)
public class DateTimeConfigurer {
private final TimeFormatConf timeFormatConf;
@EventListener(ApplicationReadyEvent.class)
public void configureTimeFormat() {
TimeZone.setDefault(TimeZone.getTimeZone(timeFormatConf.getDynamicZone()));
System.setProperty("user.timezone", timeFormatConf.getDynamicZone());
}
}
Run Code Online (Sandbox Code Playgroud)
还有 spring.factories( src/main/resources/META-INF/spring.factories):
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
[package].DateTimeConfigurer,\
...
Run Code Online (Sandbox Code Playgroud)
当我尝试自动装配 TimeFormatConf 类时,我的 spring 应用程序在启动时崩溃,因为它找不到 TimeFormatConf 类的 bean:
com.some.package.b.Class 中构造函数的参数 0 需要类型为“com.some.package.a.TimeFormatConf”的 bean,但无法找到。
该工件在类路径上具有正确的配置。所以它必须对 Spring 的声明或配置做一些事情。
我还尝试添加@Component属性类和@ComponentScan配置类没有任何效果。
在两个项目上恢复到 Spring Boot 2.7.7 解决了这个问题。所以这似乎是一个错误或至少缺乏文档。我已经提出了一个问题来与 Spring 团队跟进:https://github.com/spring-projects/spring-boot/issues/33720
java spring-boot spring-boot-starter configurationproperties
如何使用 ingress-nginx 在单个集群中配置多个外部 IP?
我可以看到 ingress-nginx 使用外部 IP 创建了一个负载均衡器服务。我认为我需要创建另一个负载均衡器服务?我如何在入口中指示要使用哪个负载均衡器?
PS我正在使用GKE。