fgonzalez
fgonzalez

Reputation: 3887

How to replace properties files by yml files in Spring boot

Is there anything special to say to Springboot to take in account as configuration yaml files instead the properties files? I'm using Maven and Springboot in a project, if I place the file application.properties in the resources file the configuration is automatically recognised by Springboot.

However just replacing the properties file by a yml file does not work, the file is not taking in account anymore.

Anything to add to splicitely say to SpringBoot to use the yml files?

Below both files:

application.properties:

# THYMELEAF (ThymeleafAutoConfiguration)
spring.thymeleaf.check-template-location=true
spring.thymeleaf.prefix=/WEB-INF/views/
spring.thymeleaf.suffix=.html
spring.thymeleaf.mode=LEGACYHTML5
spring.thymeleaf.encoding=UTF-8
spring.thymeleaf.content-type=text/html
spring.thymeleaf.cache=false

and application.yml

spring:
  profiles:
    active: ${dario.environment:dev}
  thymeleaf:
    check-template-location: true
    thymeleaf.prefix: /WEB-INF/views/
    thymeleaf.suffix: .html
    thymeleaf.mode: LEGACYHTML5
    spring.thymeleaf.encoding: UTF-8
    spring.thymeleaf.content-type: text/html
    cache: false

Upvotes: 4

Views: 8758

Answers (1)

Waleed Almadanat
Waleed Almadanat

Reputation: 1037

If you refer to the section 'Using YAML instead of Properties' in the Spring Boot reference documentation, it says that Spring Boot should pick it up automatically given you have the SnakeYAML library on your classpath.

Having that said, it also states

If you use ‘starter POMs’ SnakeYAML will be automatically provided via spring-boot-starter

Upvotes: 3

Related Questions