Junior — Middle
What method of configuration do you prefer?
sobes.tech AI
Answer from AI
I usually prefer configuration through external files (such as properties, YAML, or XML), which are easy to change without recompiling the code. In Java, it is common to use the application.properties or application.yml file in Spring Boot, allowing centralized management of settings.
The principle of separating configuration from code is also important, so that environment parameters (such as databases, ports) can be changed without modifying the application logic.
Example of using application.properties in Spring Boot:
server.port=8081
datasource.url=jdbc:mysql://localhost:3306/mydb
In the code, these parameters can be accessed via @Value annotations or the Environment bean.