I included the maven property plugin like proposed in a response to this question Specify system property to Maven project. In order to be able to set my database properties from file (and override it with maven parameters in testing environment). However if I try to access one of the properties via
System.getProperty("mysql.url")
for example null
is returned. How can I access the properties set from set properties goal.
private void initializeDatabaseConfiguration() {
url = System.getProperty("mysql.url");
con = DriverManager.getConnection(url, username, password);
}
And my maven plugin is defined like this:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0-alpha-2</version>
<executions>
<execution>
<phase>initialize</phase>
<goals>
<goal>set-system-properties</goal>
</goals>
<configuration>
<files>
<file>src/main/resources/config.properties</file>
</files>
<properties>
<property>
<name>mysql.url</name>
<value>${mysql.url}</value>
</property>
</properties>
</configuration>
</execution>
</executions>
</plugin>