Indraneel Bende
Indraneel Bende

Reputation: 3486

Significance of Spring.application.name in Bootstrap.properties

Hello I have a spring cloud config server setup. I have multiple profiles (environments): dev, prod, test, etc.

the contents of bootstrap.properties on a config client side are-

        spring.application.name=hazelcast,kafka.
        ....
        .... including uri of config server.

Now in my repository which the config server is pointing to, there is application.properties in addition to environment specific application-dev.properties, application-prod.properties etc. I also have hazelcast-dev.properties, hazelcast-prod.properties, kafka-dev.properties, kafka-prod.properties etc.

When I run my config client spring boot application with profiles.active set as dev. The config client is able to retrieve the following files from the server:

1.application.properties.

2.application-dev.properties.

3.hazelcast-dev.properties.

4.kafka-dev.properties.

And when i run with prod profiles active the corresponding prod files are retrieved (the values in them are added to spring's Environment).

Now this works and that's good, but I would like to understand the logic behind it. Is spring.application.name specifically meant for this?

http://cloud.spring.io/spring-cloud-static/spring-cloud-config/2.0.0.M5/single/spring-cloud-config.html

I went through the documentation and things weren't absolutely clear regarding it.

Thank you in advance!

EDIT-

https://cloud.spring.io/spring-cloud-static/spring-cloud.html#_application_context_hierarchies

The Section Bootstrap Application Context in the above link has almost answered my question but would appreciate someone to just confirm it.

Upvotes: 14

Views: 17013

Answers (4)

Bing Ren
Bing Ren

Reputation: 1785

If you use Spring Cloud to integrate with AWS Secrets Manager, by default it uses the spring.application.name when constructing the path for the properties to look up for this specific service.

See https://github.com/spring-attic/spring-cloud-aws/blob/main/docs/src/main/asciidoc/secrets-manager.adoc

enter image description here

Upvotes: 0

Amit Patil
Amit Patil

Reputation: 790

In addition to,

  1. Register spring application name to naming server(Netflix Eureka)
  2. Get configuration from spring cloud configuration by application name and profile.

It is also used in

  1. Spring Bus to address spring application to invoke Bus Refresh (/actuator/bus-refresh/{destination}) ad Bus Env (/actuator/bus-env/{destination}) endpoints

Addressing an Instance

Upvotes: 2

MRedant
MRedant

Reputation: 15

In case you deploy a Spring-project on Openshift; Spring uses it to find resources declared in configmaps with the same name inside your openshift-project.

Upvotes: 1

spencergibb
spencergibb

Reputation: 25177

It has a few different purposes. It is used as the application name when registering with a service registry such as eureka. It is also used to look up <applicationName>[-<profile>].[properties|yml] in configserver as well as configuration in consul or zookeeper.

Upvotes: 19

Related Questions