Can I manually load @ConfigurationProperties without the Spring AppContext?

前端 未结 5 1708
天命终不由人
天命终不由人 2021-01-02 00:28

Is there any way to load a class marked with @ConfigurationProperties without using a Spring Context directly? Basically I want to reuse all the smart logic tha

5条回答
  •  北荒
    北荒 (楼主)
    2021-01-02 00:56

    import org.springframework.boot.context.properties.bind.Binder
    val binder = Binder.get(environment)
    binder.bind(prefix, MySettings.class).get
    

提交回复
热议问题