Spring属性将完整的属性对象注入bean

时间:2019-03-15 09:30:00

标签: spring spring-boot properties dependency-properties

拥有属性类:

library("survival")
library("surv2sampleComp")
data(veteran)
# we need a group variable to use the surv2sample function
veteran$group <- as.numeric(veteran$karno < 70) 
rmst <- surv2sample(veteran$time, veteran$status, veteran$group, npert = 500, tau_start= 100, tau = 200)
rmst$group0
#---------------
                             Est.       Lower 95%   Upper 95%          SE
RMST                       43.4025761  32.1207404  55.8039197  6.15988181
# results truncated

我可以配置它:

@Getter
@Setter
@Component
@ConfigurationProperties(prefix = "my-api")
public class MyApiProperties {

    ...

    private MyClient myClient; 

    @Getter
    @Setter
    public static class MyClient {
        private String host;
        private long connectionTimeout;
        private long receiveTimeout;
    }
}

我可以注入它:

my-api:
  my-client:
    host: http://1...
    connection-timeout: 30000
    receive-timeout: 60000

但是我可以像这样注入完整的物体吗?

@Value("${my-api.my-client.host}")
private String host;

0 个答案:

没有答案