Spring Boot application properties autocompletion with profiles

Answered

Hi there, 

it seems that the autocompletion feature is not working when the application.properties is renamed to work only for a specific profile, e.g. application-dev.properties. Are there any options to enable autocompletion for renamed application.properties?

0
6 comments

Could you please provide following:

  • Screenshot of Spring Facet configuration in File > Project Structure > Project Settings > Facets > Spring (ProjectName)?

For example:

  • Screenshot of your project tool window showing the location of the .properties file?

For example:

  • If you are using Maven or Gradle for this project - please provide your pom.xml/build.gradle configuration.

  • Screenshot of Help > About popup window (to check the exact version of IntelliJ you are using).

0

I had to blur the project and module names, but I hope that it still has all the important information. The module I am showing you int he project windows is marked as a spring project in the facets. This project has a application.properties in the src/main/resource directory where the autocompletion is working, but the application-dev.properties in the config directory has no autocompletion. Maybe the problem isn't the profile but that the file is not in the classpath, but in a "config"-directory of the module.

Facets:

Project:

About:

Unfortunately, I can't share the pom.xml.

Many thanks!

0

Thanks for providing the information. Yes, the problem is caused by the application-dev.properties file not being in the classpath.

You can add a new <resource> tag under <build><resources> in your pom.xml file so that Maven can automatically add both resources and the config directory to the classpath. Here is an example screenshot of the pom.xml configuration:

Also, the .properties file icon should be different when recognized as a spring properties file - green leaf instead of a gear.

0

Hi Ivan, 

thanks for your reply.

This would most definitely work, but I actually don't want maven to know about my local application properties. That's why these are not placed at /src/main/config but at [repository-root]/config. As the repository root is alos the working directory, these files are automatically picked up by spring boot. These files should not be used during any goals run by maven, therefore I think adding them as resources is not the way to go.

Is there another way to have application.property files that are not part of the maven sources but they are recognized as spring properties files?

0

Does it help if you mark the "config" folder as a resource root?

0

Hi Ethan, this did the trick. I was expecting that a reload of the maven project would reset the config folder beign marked as resource root, but this seems to not be the case. So thank you very much!

0

Please sign in to leave a comment.