Skip to content

Difference between and

When I started learning about Spring Boot, I usually saw examples using and Then this was confusing my head. Let’s see the case where each one should be used.

The is a specific file from Spring Cloud and it’s loaded before the Important properties like and into bootstrap file. Also encryption/decryption information. See below an example of a bootstrap.yml:

    name: organizationservice
      enabled: true
  port: 8081

In the example above, the properties defined are:

  • = organizationservice this property is responsible for setting the application name
  • = default this property sets the profile defined in the config server
  • = true this property is enabling the application to connect to the config server
  • spring.server.port = 8081 here the port for the application is being defined

The is a common file to Spring Boot applications. In this file also goes important properties, but the main difference is the precedence, since has a higher priority. See below an example of an application.yml:

    preferIpAddress: true
    registerWithEureka: true
    fetchRegistry: true
      defaultZone: http://localhost:8761/eureka/

In the above example, the properties defined are:

  • eureka.instance.preferIpAddress = true this property informs Eureka service that the client wants to be advertised by IP address instead of DNS
  • eureka.client.registerWithEureka = true this property tells the application to register with Eureka
  • eureka.client.fetchRegistry = true is used to tell the Spring Eureka Client to fetch a local copy of the registry
  • eureka.client.serviceUrl.defaultZone = http://localhost:8761/eureka this comma separated attribute is used to inform the list of urls of the Eureka Service

Hope you enjoyed this post and see you soon!

For more information about this Spring Boot configuration access here . If you want to check all Spring Boot common properties go here

Published inUncategorized

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *