Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3229200
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T16:46:59+00:00 2026-05-17T16:46:59+00:00

How can I change a .properties file in maven depending on my profile? Depending

  • 0

How can I change a .properties file in maven depending on my profile? Depending on whether the application is built to run on a workstation or the datacenter parts of the file my_config.properties change (but not all).

Currently I manually change the .properties file within the .war file after hudson builds each version.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T16:47:00+00:00Added an answer on May 17, 2026 at 4:47 pm

    As often, there are several ways to implement this kind of things. But most of them are variations around the same features: profiles and filtering. I’ll show the most simple approach.

    First, enable filtering of resources:

    <project>
      ...
      <build>
        <resources>
          <resource>
            <directory>src/main/resources</directory>
            <filtering>true</filtering>
          </resource>
        </resources>
        ...
      </build>
    </project>
    

    Then, declare a place holder in your src/main/resources/my_config.properties, for example:

    myprop1 = somevalue
    myprop2 = ${foo.bar}
    

    Finally, declare properties and their values in a profile:

    <project>
      ...
      <profiles>
        <profile>
          <id>env-dev</id>
          <activation>
            <property>
              <name>env</name>
              <value>dev</value>
            </property>
          </activation>
          <properties>
            <foo.bar>othervalue</foo.bar>
          </properties>
        </profile>
        ...
      </profiles>
    </project>
    

    And run maven with a given profile:

    $ mvn process-resources -Denv=dev
    [INFO] Scanning for projects...
    ...
    $ cat target/classes/my_config.properties 
    myprop1 = somevalue
    myprop2 = othervalue
    

    As I said, there are variation around this approach (e.g. you can place values to filter in files), but this will get you started.

    References

    • Introduction to Build Profiles
    • Maven Resources Filtering

    More resources

    • A Maven2 multi-environment filter setup
    • Maven project filtering
    • Using Maven profiles and resource filtering
    • Building For Different Environments with Maven 2
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to change values in my application.properties file and I'm running into issues
Can anyone suggest approaches that will allow me to change the properties of a
You can change the connection string at run-time like this. You make the connection
Can someone tell me how i can change the .xml file that a flash
How can I change a log file path on the fly in Logback? In
I have a bunch of properties (configurations) that can change per environment. However these
I have a properties file called ApplicationResources.properties in my application with a property that
I have an application for which log4j logging is configured in a log4j.properties file.
In windows vista, how can i change the filed date modified, of any file(text/binary)
I have an application built on the Spring Framework that uses an external properties

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.