我试图使用allication.yaml将类级注释的配置具体化。但是弹簧装货不对。知道怎么做吗?
这是我的服务classI试图设置的
@Service
@DefaultProperties(threadPoolProperties = {
@HystrixProperty(name = "coreSize", value =
"${cyclone.hystrix.lease.thread.coreSize}") })
public class LeaseService {
} 和application.yml
cyclone:
hystrix:
lease:
thread:
coreSize: 10搞错了--
java.lang.IllegalArgumentException: bad property value. property name 'coreSize'. Expected int value, actual = ${cyclone.hystrix.lease.thread.coreSize} 我可以使用@Value("${cyclone.hystrix.lease.thread.coreSize}").加载相同的属性但没有处理上述案件。有关于如何正确配置这方面的帮助吗?
发布于 2017-05-23 21:10:36
为了制作spring计算占位符,在使用PropertySourcesPlaceholderConfigurer类时,需要使用静态@Bean方法注册@Configuration bean,如下所示:
@Bean
public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
return new PropertySourcesPlaceholderConfigurer();
}根据JavaDoc
PlaceholderConfigurerSupport的专门化,它解决bean定义属性值中的${.}占位符和针对当前Spring及其集合的PropertySources的@Value注释。
https://stackoverflow.com/questions/44143918
复制相似问题