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 6738341
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:21:26+00:00 2026-05-26T11:21:26+00:00

I have a simple spring mvc app, using maven with intellij. How do you

  • 0

I have a simple spring mvc app, using maven with intellij.

How do you go about creating seperate files for both production and development?

e.g. say I want to set a production and development mysql connection string for nhibernate?

How can I have it such that when I build it will take the correct file to use to grab configuration information? (and any advice on naming conventions for the files?)

  • 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-26T11:21:26+00:00Added an answer on May 26, 2026 at 11:21 am

    Using an ant task is pretty straight forward for this.

    First, create a couple profiles under <project> in your pom:

    <profiles>
      <profile>
        <id>build-dev</id>
        <activation>
          <!-- <activeByDefault>true</activeByDefault> -->
          <property>
            <name>env</name>
            <value>dev</value>
          </property>
        </activation>
        <properties>
          <config.name>config.dev.properties</config.name>
        </properties>
      </profile>
      <profile>
        <id>build-prod</id>
        <activation>
          <property>
            <name>env</name>
            <value>prod</value>
          </property>
        </activation>
        <properties>
          <config.name>config.prod.properties</config.name>
        </properties>
      </profile>
    </profiles>
    

    Then use the maven-antrun-plugin

    <plugins>
      <plugin>
        <artifactId>maven-antrun-plugin</artifactId>
        <executions>
          <execution>
            <phase>prepare-package</phase>
            <goals>
              <goal>run</goal>
            </goals>
            <configuration>
              <tasks>
                <delete file="${project.build.outputDirectory}/config.properties"/>
                <copy file="src/main/resources/${config.name}" tofile="${project.build.outputDirectory}/config.properties"/>
                <delete file="${project.build.outputDirectory}/config.dev.properties"/>
                <delete file="${project.build.outputDirectory}/config.prod.properties"/>
              </tasks>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
    

    Now you just specify the profile you want when you run mvn. If you want a default, uncomment and place the:

    <!-- <activeByDefault>true</activeByDefault> -->
    

    section in the profile you want by default. As it is, the build will fail on the ant task if neither is specified.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using IDEA and tomcat I setup a simple spring mvc app (thanks to you
I have my web application written in Spring MVC. It is quite simple app
I have what I thought was a simple Spring MVC app. However, I can
I have an extremely simple web application running in Tomcat using Spring 3.0.2, Hibernate
I have what seems like a simple problem. I have a Spring web app,
So I have a spring mvc web application that I built in IntelliJ 9,
I have a spring mvc app that I want to refactor out, speficially removing
I've written a really simple Spring MVC app. I apologise I'm rather new to
Newbie question. I’m writing an ASP.Net MVC app in VB.Net and have been using
Spring MVC web app: I have a stack trace w/o line numbers (shown at

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.