I'm trying to use the @Value to load some value from application.properties based on the profile, but there is something that does not work...
In my application.properties I have
[email protected]@
I have
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
in my pom.xml. When compiling, i see that my application.properties has the right value of jdbc.url
Then i want to use this property when connecting to the DB
@Value("${jdbc.url}")
private String dbUrl;
@PostConstruct
public Connection getConnection(){
Class.forName("com.mysql.jdbc.Driver");
return DriverManager.getConnection(dbUrl, "user", "xxxxxxx");
}
but dbUrl is null... Do i need something else?
spring.datasource.url!=jdbc.url)..... Also I would say what you are doing (first using maven to replace variables) is wrong to begin with...Connectionmanually anyway? Doing this sort of thing automatically is the whole point of using Boot.