.properties vs .yml in Spring

application.properties file

@PropertySource annotation to externalize your configuration to a properties file.

@PropertySource(value = "application.properties", ignoreResourceNotFound = true)

application.yml

@PropertySource annotation can’t support this file type.

key:
 value: 2329423
@Value("${key.value}")
private String abc;
  • In the class

If you want to handle multiple profiles, 

  • .properties file : In this case you need to manage individual file for each profile. 
  • .yml file : In this file type you just need to manage single file and place configuration data of specific profile inside it.

Leave a Reply

Your email address will not be published.

ANOTE.DEV