title: In spring boot how to load a yml section as java.util.Properties
body: <p>In my spring boot application, I have following configuration:</p>
  
  <pre><code>server:
    host: a.com
    port: 5922
    enable-log: true
  </code></pre>
  
  <p>I want to read the above as a <code>java.util.Properties</code>. I tried putting following class:</p>
  
  <pre><code>@ConfigurationProperties(prefix = "server")
  public class ServerConfig {
    private Properties serverProps;
    // ... Getter/setter
  }
  </code></pre>
  
  <p>The boot config files look like:</p>
  
  <pre><code>@Configuration
  @ComponentScan("com.demo")
  @EnableAspectJAutoProxy(proxyTargetClass = true)
  @EnableConfigurationProperties({ServerConfig.class})
  @Profile({"dev"})
  public class TestAppConfiguration {
  }
  
  @EnableAutoConfiguration
  @SpringBootApplication
  public class TestAppInitializer {
    public static void main(final String[] args) {
      SpringApplication.run(TestAppInitializer.class, args);
    }
  }
  </code></pre>
  
  <p>Unit test class:</p>
  
  <pre><code>@SpringApplicationConfiguration(classes = {TestAppInitializer.class})
  @ActiveProfiles("dev")
  public class ServerConfigTest extends AbstractTestNGSpringContextTests {
    @Autowired
    private ServerConfig serverConfig;
  
    @Test
    public void printDetails() {
      logger.debug("ServerConfig.properties --&gt; {}", serverConfig.getProperties());
    }
  }
  </code></pre>
  
  <p>The output is 
  <strong><code>ServerConfig.properties --&gt; null</code></strong>.</p>
  
  <p>I am not sure why is this happening. The only idea that comes to my mind is, the configuration parameters underneath <code>server</code> are basically flat strings. Is there any way I can read those as <code>Properties</code>?</p>