In Maven projects, while editing
pom.xml, one needs to define a property and replace the occurrences of some value - artifact version, for example, - with this property.
Extract Property refactoring creates a new property definition in the specified
pom.xml file, finds all the occurrences of the selected string in the hierarchy of
pom.xml files, and replaces them with the above property in the format:
To extract a property
- Place the cursor within the expression or declaration of a variable to be replaced with a property.
- Choose Refactor | Extract | Property in the main menu, or on the context menu.
- If more than one occurrence of the expression is found within the class, specify whether you wish to replace only the selected occurrence, or all the found occurrences with the new property.
- Choose the semantic for the property.
- If you want the constant to be defined in the private category, select the Put to private category check box.
- To complete the refactoring, press ⇥ or ⏎.
If you haven't completed the refactoring and want to cancel the changes you have made, press ⎋.