title: How to convert from application.properties to application.yml in Spring Boot?
body: <p>I have a very simple Spring Boot app and I have application.properties, and now I want to move to application.yml</p>
  
  <p>This is the application.yml file:</p>
  
  <pre><code>spring:
      datasource:
          url: jdbc:mysql://localhost:3306/employee_directory
          username: student
          password: Password123
  </code></pre>
  
  <p>So I've deleted application.properties file and I've written the application.yml file. If I run the app I get this exception:</p>
  
  <pre><code>   20:31:22.446 [restartedMain] ERROR org.springframework.boot.SpringApplication - Application run failed
  java.lang.IllegalStateException: Failed to load property source from location 'classpath:/application.yml'
      at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.load(ConfigFileApplicationListener.java:524)
      at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.loadForFileExtension(ConfigFileApplicationListener.java:473)
      at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.load(ConfigFileApplicationListener.java:443)
      at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.lambda$null$6(ConfigFileApplicationListener.java:425)
      at java.lang.Iterable.forEach(Iterable.java:75)
      at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.lambda$load$7(ConfigFileApplicationListener.java:425)
      at java.lang.Iterable.forEach(Iterable.java:75)
      at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.load(ConfigFileApplicationListener.java:422)
      at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.load(ConfigFileApplicationListener.java:321)
      at org.springframework.boot.context.config.ConfigFileApplicationListener.addPropertySources(ConfigFileApplicationListener.java:202)
      at org.springframework.boot.context.config.ConfigFileApplicationListener.postProcessEnvironment(ConfigFileApplicationListener.java:186)
      at org.springframework.boot.context.config.ConfigFileApplicationListener.onApplicationEnvironmentPreparedEvent(ConfigFileApplicationListener.java:176)
      at org.springframework.boot.context.config.ConfigFileApplicationListener.onApplicationEvent(ConfigFileApplicationListener.java:164)
      at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
      at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
      at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
      at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:127)
      at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:75)
      at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:53)
      at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:340)
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:304)
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:1213)
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:1202)
      at com.dgs.springboot.SpringBootRESTJPA.SpringBootRestJPAApplication.main(SpringBootRestJPAApplication.java:10)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)
  Caused by: org.yaml.snakeyaml.scanner.ScannerException: while scanning for the next token
  found character '\t(TAB)' that cannot start any token. (Do not use \t(TAB) for indentation)
   in 'reader', line 2, column 1:
          datasource:
      ^
  
      at org.yaml.snakeyaml.scanner.ScannerImpl.fetchMoreTokens(ScannerImpl.java:419)
      at org.yaml.snakeyaml.scanner.ScannerImpl.checkToken(ScannerImpl.java:227)
      at org.yaml.snakeyaml.parser.ParserImpl$ParseBlockMappingValue.produce(ParserImpl.java:586)
      at org.yaml.snakeyaml.parser.ParserImpl.peekEvent(ParserImpl.java:158)
      at org.yaml.snakeyaml.parser.ParserImpl.checkEvent(ParserImpl.java:148)
      at org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:124)
      at org.yaml.snakeyaml.composer.Composer.composeValueNode(Composer.java:236)
      at org.yaml.snakeyaml.composer.Composer.composeMappingChildren(Composer.java:227)
      at org.yaml.snakeyaml.composer.Composer.composeMappingNode(Composer.java:215)
      at org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:144)
      at org.yaml.snakeyaml.composer.Composer.getNode(Composer.java:85)
      at org.yaml.snakeyaml.constructor.BaseConstructor.getData(BaseConstructor.java:123)
      at org.yaml.snakeyaml.Yaml$1.next(Yaml.java:547)
      at org.springframework.beans.factory.config.YamlProcessor.process(YamlProcessor.java:160)
      at org.springframework.beans.factory.config.YamlProcessor.process(YamlProcessor.java:134)
      at org.springframework.boot.env.OriginTrackedYamlLoader.load(OriginTrackedYamlLoader.java:75)
      at org.springframework.boot.env.YamlPropertySourceLoader.load(YamlPropertySourceLoader.java:49)
      at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.loadDocuments(ConfigFileApplicationListener.java:542)
      at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.load(ConfigFileApplicationListener.java:497)
      ... 28 common frames omitted
  </code></pre>
  
  <p>I think I need to make other modification to my code to use this application.yml file but I don't know what to do?</p>
  
  <p>This is pom.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
      &lt;parent&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
          &lt;version&gt;2.1.6.RELEASE&lt;/version&gt;
          &lt;relativePath/&gt; &lt;!-- lookup parent from repository --&gt;
      &lt;/parent&gt;
      &lt;groupId&gt;com.dgs.springboot&lt;/groupId&gt;
      &lt;artifactId&gt;SpringBootRESTHibernate&lt;/artifactId&gt;
      &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
      &lt;name&gt;SpringBootRESTHibernate&lt;/name&gt;
      &lt;description&gt;Demo project for Spring Boot&lt;/description&gt;
  
      &lt;properties&gt;
          &lt;java.version&gt;1.8&lt;/java.version&gt;
          &lt;!-- Add work around for Eclipse bug --&gt;
          &lt;maven-jar-plugin.version&gt;3.1.1&lt;/maven-jar-plugin.version&gt;
      &lt;/properties&gt;
  
      &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-data-jpa&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-devtools&lt;/artifactId&gt;
              &lt;scope&gt;runtime&lt;/scope&gt;
              &lt;optional&gt;true&lt;/optional&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;mysql&lt;/groupId&gt;
              &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;
              &lt;scope&gt;runtime&lt;/scope&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
            &lt;groupId&gt;org.projectlombok&lt;/groupId&gt;
            &lt;artifactId&gt;lombok&lt;/artifactId&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-test&lt;/artifactId&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
  
      &lt;build&gt;
          &lt;plugins&gt;
              &lt;!-- This is used for packaging and running our app --&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
                  &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/build&gt;
  
  &lt;/project&gt;
  </code></pre>
  
  <p>Any feedback will be appreciated. Thank you!</p>