spring-boot-configuration-processor 是否处理带注释的 bean 方法?
Does spring-boot-configuration-processor process annotated bean methods?
spring-boot-configuration-processor
是否处理带注释的 bean 方法?
因为就我而言,它没有。
这是我的代码:
@Data
public class DatasourceConnectionPoolProperties {
private Integer initialSize;
private Integer maxIdle;
private Integer minIdle;
private Integer timeBetweenEvictionRunsMillis;
private Integer minEvictableIdleTimeMillis;
private Boolean testOnBorrow;
private String validationQuery;
}
并且在@Configuration-annotated class的某处:
@Bean
@ConfigurationProperties("persistence.pool")
protected DatasourceConnectionPoolProperties localPoolProperties() {
return new DatasourceConnectionPoolProperties();
}
编译期间,没有生成元数据。但是,当 DatasourceConnectionPoolProperties
被生成 @ConfigurationProperties
元数据注释时。
我是不是哪里弄错了,还是只是spring-boot-configuration-processor
限制?
它确实如此,但注释处理器只查找 public
方法,而你的是 protected
(顺便说一下,这对于 @Bean
方法来说非常不寻常)。
spring-boot-configuration-processor
是否处理带注释的 bean 方法?
因为就我而言,它没有。
这是我的代码:
@Data
public class DatasourceConnectionPoolProperties {
private Integer initialSize;
private Integer maxIdle;
private Integer minIdle;
private Integer timeBetweenEvictionRunsMillis;
private Integer minEvictableIdleTimeMillis;
private Boolean testOnBorrow;
private String validationQuery;
}
并且在@Configuration-annotated class的某处:
@Bean
@ConfigurationProperties("persistence.pool")
protected DatasourceConnectionPoolProperties localPoolProperties() {
return new DatasourceConnectionPoolProperties();
}
编译期间,没有生成元数据。但是,当 DatasourceConnectionPoolProperties
被生成 @ConfigurationProperties
元数据注释时。
我是不是哪里弄错了,还是只是spring-boot-configuration-processor
限制?
它确实如此,但注释处理器只查找 public
方法,而你的是 protected
(顺便说一下,这对于 @Bean
方法来说非常不寻常)。