Answer the question
In order to leave comments, you need to log in
Spring application.properties how to do?
Greetings dear forum users.
Here I read here https://stackoverflow.com/questions/32058814 and I can't make out the solution. Solution with 100 likes.
I'm trying to do it, but it turns out what kind of mess. Can someone please explain the solution to this?
Answer the question
In order to leave comments, you need to log in
Hello!
Easily...
1) Create a class for example,
@Configuration
@ConfigurationProperties(prefix = "custom")
public class AppProperties {
// названия полей должны соответствовать названиям из properties.
private String baseUrl;
private String uploadPath;
// тут геттеры
}
custom.base_url=http://localhost:8080
custom.upload_path=/home/example.com/uploads
@ConfigurationProperties(prefix = "custom")
custom.base_url
custom is a prefix. Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question