【发布时间】:2022-01-19 07:43:42
【问题描述】:
我正在使用 Spring Boot 和 Lombock,并且我有一个使用一些 String 属性初始化的 bean,并将它们提供给其他类:
@Getter
@Configuration
@PropertySource(value = "classpath:texts.properties")
public class TextProvider {
@Value("${some.text.value}")
private String text1;
@Value("${other.text.value}")
private String text2;
}
当 Lombok 为这个类创建 getter 时,它会将 @Value 注解复制到 get 方法中,导致 Spring 的 AutowiredAnnotationBeanPostProcessor 在系统启动时打印以下信息: "自动装配注解只能用于带参数的方法:" + 方法。
有没有办法不将这些注解复制到 getter 中?
【问题讨论】:
标签: java spring-boot lombok