Build Profiles

Build Profiles

In general, profiles are used to customize the build life cycle for different environments like development, testing, production, etc.

<profiles>
   <profile>
      <id>development</id>
      <activation>
         <activeByDefault>true</activeByDefault>
      </activation>
      <properties>       
        <jdbc.connection.url>jdbc:oracle:thin:@localhost:1521:xe</jdbc.connection.url>
      </properties>
   </profile>
   <profile>
      <id>test</id>
      <properties>
         <jdbc.connection.url>jdbc:mysql://localhost:3306/ashokdb</jdbc.connection.url>
      </properties>
   </profile>
</profiles>

Where each and every profile has its own id, it can be used to access the respective environment or profile.

In src/main/resources/db.properties
jdbc.connection.url = ${jdbc.connection.url} 

If we provide the above setups like above then at compilation time, the respective jdbc URL will be injected to the “jdbc.connection.url” property depending on the target environment. Use the following command on command prompt inorder to compile the project.

mvn compile

Here “jdbc.connection.profile” property

will take “jdbc:oracle:thin:@localhost:1521:xe” value.

mvn compile -Ptest

Here “jdbc.connection.profile” property

will take “jdbc:mysql://localhost:3306/ashokdb” value.

jdbc.connection.url = ${jdbc.connection.url}

If we provide the above setups like above then at compilation time, the respective jdbc URL will be injected to the “jdbc.connection.url” property depending on the target environment.

Build Profiles


Scroll to top