title: how to load config in spring-webflux without spring-boot?
body: <p>I just take some experiments with spring webflux 5.0.0 and Kotlin, and I have problem with loading configuration from application.yml</p>
  
  <p>For base project I start with this example <a href="https://github.com/sdeleuze/spring-kotlin-functional" rel="noreferrer">spring-kotlin-functional</a> <br> 
  But there are only manual loading beans and routing without any loading from configuration files or example how to implement analog of @ConfigurationProperties class in such way.</p>
  
  <p>I have try to take environment in beans section:</p>
  
  <pre><code>data class DbConfig(
      var url: String = "",
      var user: String = "",
      var password: String = ""
  )
  
  fun beans(): BeanDefinitionDsl = beans {
      bean {
          //try to load config from path=db to data class DbConfig
          env.getProperty("db", DbConfig::class.java)
      }
  
      bean&lt;DBConfiguration&gt;()
  
      //controllers
      bean { StatsController(ref()) }
      bean { UserController(ref()) }
  
      //repository
      bean { UserRepository(ref()) }
  
      //services
      bean { StatsService(ref()) }
  
      //routes
      bean { Routes(ref(), ref()) }
      bean("webHandler") {
          RouterFunctions.toWebHandler(ref&lt;Routes&gt;().router(), HandlerStrategies.builder().viewResolver(ref()).build())
      }
  
      //view resolver
      bean {
          val prefix = "classpath:/templates/"
          val suffix = ".mustache"
          val loader = MustacheResourceTemplateLoader(prefix, suffix)
          MustacheViewResolver(Mustache.compiler().withLoader(loader)).apply {
              setPrefix(prefix)
              setSuffix(suffix)
          }
      }
  }
  </code></pre>
  
  <p>but there are only system properties in Environment</p>
  
  <p>So the question is how to load configuration from application.yml and how to implement analog of @ConfigurationProperties in such functional style? </p>
  
  <p>And do I understand correctly that without spring-boot all annotations (like @Bean, @Repository, @Transactional and other) will not work for Beans? </p>
  
  <p>My sources: <a href="https://github.com/evgzakharov/big_migration/tree/0.0.1/step4_migration_to_webflux" rel="noreferrer">github</a></p>
  
  <p><strong>Update 2017-10-21</strong></p>
  
  <p>Find a solution. The problem was related to the fact that there there were no any BeanPostProcessor. And after I include this two processors:</p>
  
  <pre><code>bean&lt;CommonAnnotationBeanPostProcessor&gt;()
  bean&lt;ConfigurationClassPostProcessor&gt;() 
  </code></pre>
  
  <p>annotations <code>@Configuration</code>,<code>@Bean</code> and <code>@PostConstruct</code> start to work. But annotation <code>@ConfigurationProperties</code> exists only in <code>spring-boot</code> dependency, and yml parsing classes I find only in <code>spring-boot-starter</code>..</p>
  
  <p>After including dependency <code>spring-boot-starter</code> and adding <code>bean&lt;ConfigurationPropertiesBindingPostProcessor&gt;()</code> to beans section, annotation <code>@ConfigurationProperties</code> start to work, but config from application.yml was also not included. So I add this section:</p>
  
  <pre><code>val resource = ClassPathResource("/application.yml")
  val sourceLoader = YamlPropertySourceLoader()
  val properties = sourceLoader.load("main config", resource, null)
  environment.propertySources.addFirst(properties)
  </code></pre>
  
  <p>to <code>GenericApplicationContext</code> configuration. And now all work as I expect, but with including a dependency <code>spring-boot-starter</code>. </p>
  
  <p>Full code sample: <a href="https://github.com/evgzakharov/big_migration/tree/1.0.0/step4_migration_to_webflux" rel="noreferrer">version with fixes</a></p>