引用以下问题https://github.com/watson-developer-cloud/spring-boot-starter/issues/7 。我们必须将 java 文件中的前缀更改为 kebab-case 。但是,如果依赖项 jar 文件之一引用 @ConfigurationProperties(prefix="MY_CONFIG") 等格式的前缀,该怎么办?这个问题有解决办法吗?
最佳答案
Is there a solution to this problem ?
我假设您使用的是 Spring Boot 2.x。它收紧了有关宽松绑定(bind)的一些规则,因此现在需要在 @ConfigurationProperties
的 前缀
中使用规范形式 (kebab-case)。 (application.properties 文件中仍然支持 Camel case、snake case 和 kebab case)。
唯一的解决方案是更新所有@ConfigurationProperties
注释以满足Spring Boot 2.0的要求。在这种情况下,需要更改您的依赖项 jar。请注意,在 kebab-case 中带有前缀的 @ConfigurationProperties
注解将适用于 Spring Boot 1.x 和 2.x,因此您不会因更改而遇到任何向后兼容性问题。
关于spring - spring boot 2.x kebab-case 格式的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52282608/