In my Maven build I would like to be able to define default values (e.g. for database connection) in pom.xml, but I would like the user to be able to override these without having to modify pom.xml
directly.
By way of example, in an Ant build you can define default properties in foo.properties
, but Ant will look for overrides for each of these in a foo.$USERNAME.properties
. The latter is generally not checked into source control, which eliminates the problem of developers accidentally committing their overrides of the default properties. Does Maven offer a similar facility?
To make the problem a bit more concrete, assume I have the following defined in pom.xml
<properties>
<db.url>jdbc:jtds:sqlserver://10.10.10.10:1433/somedb</db.url>
<db.driver>net.sourceforge.jtds.jdbc.Driver</db.driver>
<db.username>default_user</db.username>
<db.password>secret</db.password>
</properties>
Can a user override these properties without editing the pom.xml directly?
You can specify properties on the command line using -Dpropertyname=value
, or the user can specify properties in their .m2/settings.xml
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With