I am a beginner in Spring Boot.
I have a project in Spring Boot which has a application.properties
and the inside has a property with a value ( spring.datasource.username=user
) and I want to get this value in a class java mine, I will use this value to make the connection with the bank in jdbc, but I can not get the value, it always comes null, I searched the internet and found many examples using something like:
@Value("${spring.datasource.username}")
private String username;
or
@Value("#{environment['spring.datasource.username']}")
private String username;
but both cases my username property is always null. Can someone help me?
Edit 1:
In red this is the class I want to get the value of the property spring.datasource.username
that is in application.properties
;
In yellow this file application.properties