如何将@ConfigurationProperties与记录一起使用?
2022-09-03 12:21:47
Java 16 引入了 Records,这有助于在编写携带不可变数据的类时减少样板代码。当我尝试使用记录作为bean,如下所示,我收到以下错误消息:@ConfigurationProperties
@ConfigurationProperties("demo")
public record MyConfigurationProperties(
String myProperty
) {
}
***************************
APPLICATION FAILED TO START
***************************
Description:
Parameter 0 of constructor in com.example.demo.MyConfigurationProperties required a bean of type 'java.lang.String' that could not be found.
如何使用记录作为?@ConfigurationProperties