有没有什么特别的要说给Springboot注意作为配置yaml文件而不是属性文件?我正在一个项目中使用Maven和Springboot,如果我把application.properties文件放在资源文件夹中,配置将自动被Springboot识别。
然而,只是用yml文件替换属性文件是不起作用的,文件不再被考虑在内。
是否需要添加一些内容明确告诉SpringBoot使用yml文件?
以下是两个文件:
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
以及 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