/
How to override Maven properties

How to override Maven properties

We use Maven to configure our web applications but some properties might be specific for your system. You can override them in the following way.

Step-by-step guide

  1. Go to your home directory and find the folder ".m2".
  2. In there might be a file called "settings.xml".
  3. If there is no such file, create a new file called settings.xml.
  4. Open that file. If it's empty add the following lines to it:
<settings>
	<profiles>
		<profile>
			<id>dev</id>
			<properties>
				<property-you-like-to-override>value</property-you-like-to-override>
			</properties>
		</profile>
	</profiles>
</settings>

(Replace "property-you-like-to-override" with the name of the property you want to override, and "value" with the value. Replace the profile "id" (in the example "dev") with the id of the profile you want to be used. In the above example the property "property-you-like-to-override" will have the value "value" when Maven is running.)

      5. Go to Eclipse > Settings... > Maven > User Settings. Under "User Settings:" field, add the path to your settings.xml file into the field (e.g. /Users/user/.m2/settings.xml) and then click "Apply and Close".

      6. If you have yet to establish a profile id, right-click on the project and navigate to Maven > Select Maven Profiles. Select the profile id that you just input into the <id> field and click "OK".   

If you have any issues adding the settings.xml file, it is probably due to XML syntax errors. To fix, use an online XML formatter to fix errors.

Related content

Tutorial #1 - Spring
Tutorial #1 - Spring
More like this
Part 1: Setup
Part 1: Setup
More like this
UnmappableCharacterException error in pom.xml plugin
UnmappableCharacterException error in pom.xml plugin
More like this
How to write high-quality code (Java)
How to write high-quality code (Java)
More like this