
In general, expressions are much more powerful and besides property dereferencing you can use them to do many other things. The annotation accepts the key of the property you want to inject as: The annotation works in bean constructors and directly on bean fields. You can simply inject a property value using the annotation. Injecting properties with you define your first custom property, you’re ready to use it inside your Spring beans. You use other parts to logically group several properties. The last part of the key should describe the purpose of the property. You build up a key from several parts split by the dot sign. Under those circumstances, you can think about the keys as fully qualified Java class names. However, it’s a good idea to keep the naming convention proposed in the predefined Spring Boot properties to improve the readability of the file. You may wonder if there is any specific syntax for property keys. Each line contains a property key, the equals sign, and a value of the property. The application.properties file is just a regular text file. All you have to do is to create a new file under the src/main/resources directory. Spring Boot loads the application.properties file automatically from the project classpath.

You can bundle the configuration file in your application jar or put the file in the filesystem of the runtime environment and load it on Spring Boot startup. The application.properties file is nothing more than simple key-value storage for configuration properties. If that’s what you’re looking for, keep on reading. This post covers defining custom properties, handling data types, and working with properties on different runtime environments. You can easily find common keys in the official documentation. Working with existing configuration keys is pretty straightforward. I’m not going to discuss properties specified by the Spring Boot framework.

In this article, I’ll show you how to effectively use the application.properties file in custom scenarios. Spring Boot comes with a built-in mechanism for application configuration using a file called application.properties.
