In Spring boot 2.X versions actuator base-path is set to default of '/actuator' I am using 2.2.4 and 2.3.1 and in both versions I can see that the default base-path of actuator is overwritten and set to '' sometimes. In both cases I am configuring the management.server.servlet.context-path=/manage and I am trying to access the health endpoint under /manage/actuator/health but its available under /manage/health because base-path is overwritten.

I tried to debug and find the conditions in which the default base-path is reset. It happens when ConfigurationPropertiesBindingPostProcessor.postProcessBeforeInitialization is called. I am still trying to narrow down the issue but have not configured any @ConfigurationProperties in my project.

In any case the default base-path of the actuator is reset and the documentation says its reset only when we explicitly set it.

Comment From: wilkinsona

Thanks for the report. There's nothing, as far as I am aware, in Spring Boot itself that will overwrite the actuator's base path so I suspect the cause is something that is specific to your application or environment. If you would like us to spend some more time investigating, please spend some time providing a complete yet minimal sample that reproduces the problem. You can share it with us pushing it to a separate repository on GitHub or by zipping it up and attaching it to this issue.

Comment From: DeviRoopshekar

I was able to find the root cause of this issue, so the management.web.base-path: is read from any profile in the class-path. I have attached a sample project in which I am running the local profile and it will still read the base-path from 'bootstrap.yml' in the class-path (I have a 'bootstrap-local.yml'). Also Even if I remove the 'bootstrap.yml' and if any of the dependencies have 'application.yml' and base-path is configured it reads from there too.

Test steps for the attached application 1. Just run the application to see the actuator base-path set to '' 2. Remove the 'bootstrap.yml' 3. It will read the base-path from demo dependency added which has 'application.yml' and sets the base-path to ''

actuator-basepath.zip

Comment From: wilkinsona

Thanks for the sample, @DeviRoopshekar. Unfortunately, I can't tell how I'm supposed to run it. The target directory suggests that it's a Maven project but there's no pom.xml file. However, I think it's given me sufficient information to identify the problem.

By default application.yml files are loaded from the classpath, with the first one that is found being used. If you have a dependency with an application.yml file in it and it's the first one of the classpath, it will be used. Generally speaking dependencies should not contain application.yml or application.properties files. As suggested by their name they belong in the application itself rather than in its dependencies.

If I have misunderstood the problem, please update the sample so that we can build it and run it. Otherwise, if you have any further questions, please follow up on Stack Overflow or Gitter. As mentioned in the guidelines for contributing, we prefer to use GitHub issues only for bugs and enhancements.

Comment From: DeviRoopshekar

Sorry about the attachment. I have removed the dependency with application.yml and and run the application with local profile, why does it take the bootstrap.yml even though I am using the local profile?

actuator-basepath.zip

Comment From: wilkinsona

why does it take the bootstrap.yml even though I am using the local profile?

That's how externalised configuration in Spring Boot works. Both standard configuration files are profile-specific configuration files are loaded, with properties defined in the profile-specific configuration taking precedence over those in standard configuration files. management.endpoints.web.base-path isn't defined in bootstrap-local.yml so the value in bootstrap.yml is used.

As I said above, if you have any further questions, please follow up on Stack Overflow or Gitter.