How do I configure my maven pom to create another environment?

I have 3 environments:

  • local (dev)
  • staging
  • production

each environment uses different property files (for example, to specify jdbc properties). my maven project is currently building a war file. can someone please give me some advice on how to modify the file pom.xmlso that I can specify different assemblies?

for example, if I need to build a military file for a scene, what do I need to do for the pom.xml file for this to happen, in order to use the properties files for the experience (included in the war)?

Let me be a little clearer with my build. I am using spring mvc, so I can switch which environment (e.g. property files) is present. the way this is done is to set the context parameter in web.xml as follows.

<context-param>
 <param-name>spring.profiles.active</param-name>
 <param-value>dev</param-value>
</context-param>

so basically, if I use maven profiles, how do I change this parameter value?

+4
source share
1 answer

You need to define different environment profiles in your pom.xml

<profiles>
  <profile>
    <activation>
      <property>
        <name>environment</name>
        <value>test</value>
      </property>
    </activation>
    ...
  </profile>
</profiles>

or give it a specific name / name like this

<profiles>
  <profile>
    <id>profile-1</id>
    ...
  </profile>
</profiles>

and run mvnusingmvn groupId:artifactId:goal -Pprofile-1

You can find more information here.

+1
source

Source: https://habr.com/ru/post/1530452/


All Articles