Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Maven allows you to define properties in the project's POM. You can do this using a POM file similar to the following:</p> <pre><code>&lt;project&gt; ... &lt;properties&gt; &lt;server.url&gt;http://localhost:8080/manager/html&lt;/server.url&gt; &lt;/properties&gt; ... &lt;build&gt; &lt;plugins&gt; &lt;plugin&gt; ... &lt;configuration&gt; &lt;url&gt;${server.url}&lt;/url&gt; &lt;server&gt;tomcat&lt;/server&gt; &lt;/configuration&gt; ... &lt;/plugin&gt; &lt;/plugins&gt; &lt;/build&gt; &lt;/project&gt; </code></pre> <p>You can avoid specifying the property within the <code>properties</code> tag, and pass the value from the command line as:</p> <pre><code>mvn -Dserver.url=http://localhost:8080/manager/html some_maven_goal </code></pre> <p>Now, if you don't want to specify them from the command line and if you need to further isolate these properties from the project POM, into a properties file, then you'll need to use the <a href="http://mojo.codehaus.org/properties-maven-plugin/">Properties Maven plugin</a>, and run it's <code>read-project-properties</code> goal in the <a href="http://mojo.codehaus.org/properties-maven-plugin/usage.html">initialize phase of the Maven lifecycle</a>. The example from the plugin page is reproduced here:</p> <pre><code>&lt;project&gt; &lt;build&gt; &lt;plugins&gt; &lt;plugin&gt; &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt; &lt;artifactId&gt;properties-maven-plugin&lt;/artifactId&gt; &lt;version&gt;1.0-alpha-2&lt;/version&gt; &lt;executions&gt; &lt;!-- Associate the read-project-properties goal with the initialize phase, to read the properties file. --&gt; &lt;execution&gt; &lt;phase&gt;initialize&lt;/phase&gt; &lt;goals&gt; &lt;goal&gt;read-project-properties&lt;/goal&gt; &lt;/goals&gt; &lt;configuration&gt; &lt;files&gt; &lt;file&gt;etc/config/dev.properties&lt;/file&gt; &lt;/files&gt; &lt;/configuration&gt; &lt;/execution&gt; &lt;/executions&gt; &lt;/plugin&gt; &lt;/plugins&gt; &lt;/build&gt; &lt;/project&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload