Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Environment independent single .war generation

  1. #1
    Junior Member
    Join Date
    Oct 2014
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Environment independent single .war generation

    Hi All,

    I have a project which has a set of configuration files, where each configuration file represents an environment specific configurations. In other words, I have 3 environments, development, staging, and production. The configuration for each environment is different, e.g. DB name, url etc.

    Whenever I want to deploy the same code, on each environment, I have to manually generate environment specific .war file, so that it has environment specific configuration file in it.

    What I am looking for is a kind of solution where i have to compile only once in maven and it generates only one .war file, which I can use on every environment. In other words, i want the environment specifi application server/tomcat to identify which configuration to pick.

    That way, I'll be sure that we are deploying and testing the same .war file on every environment/application server.

    How can i restructure the application to achieve this functionality?

    Thanks.


  2. #2
    Forum VIP
    Join Date
    Jul 2010
    Posts
    1,676
    Thanks
    25
    Thanked 329 Times in 305 Posts

    Default Re: Environment independent single .war generation

    Okay, I'm a bit confused. You said:
    1. each environment needs its own configurations
    2. you want a single, general war instead of 3 environment-specific wars
    If so, how would the configurations be included? Would it be like one large configuration file which includes all 3 environment configurations or something, and you want the specific environment configuration chosen at runtime?
    NOTE TO NEW PEOPLE LOOKING FOR HELP ON FORUM:

    When asking for help, please follow these guidelines to receive better and more prompt help:
    1. Put your code in Java Tags. To do this, put [highlight=java] before your code and [/highlight] after your code.
    2. Give full details of errors and provide us with as much information about the situation as possible.
    3. Give us an example of what the output should look like when done correctly.

    Join the Airline Management Simulation Game to manage your own airline against other users in a virtual recreation of the United States Airline Industry. For more details, visit: http://airlinegame.orgfree.com/

  3. #3
    Junior Member
    Join Date
    Oct 2014
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Environment independent single .war generation

    Quote Originally Posted by aussiemcgr View Post
    Okay, I'm a bit confused. You said:
    1. each environment needs its own configurations
    2. you want a single, general war instead of 3 environment-specific wars
    If so, how would the configurations be included? Would it be like one large configuration file which includes all 3 environment configurations or something, and you want the specific environment configuration chosen at runtime?
    Thanks for replying, aussiemcgr.

    I would like to keep three configuration files in the single jar, but would want each application server to pick the correct one somehow.

    Or maybe takeout the configuration files out from my source folder and make each configuration file part of specific application server.

    Or there could be any other solution that fits my requirement, i.e. one .war file to be deployed on all the servers.

    If I keep a single big configuration file and replicate the parameters but with different environment specific values then it is not a very elegant solution in my opinion.

    The requirement is when i do a dev testing using a .war, i want that same .war to go onto the staging and production. Right now it is not the case, the dev testing is done on one .war and another .war is generated and put on staging, similarly another .war on production system. I want to improve this workflow and make sure we are usign the same .war on production system that we deployed on dev and tested on staging.

    thanks.

  4. #4
    Forum VIP
    Join Date
    Jul 2010
    Posts
    1,676
    Thanks
    25
    Thanked 329 Times in 305 Posts

    Default Re: Environment independent single .war generation

    Have you done any research into profiles?
    I'm not sure how much help this will be, but it sounds like this article might be a good starting point for you: Maven – Building For Different Environments with Maven 2
    NOTE TO NEW PEOPLE LOOKING FOR HELP ON FORUM:

    When asking for help, please follow these guidelines to receive better and more prompt help:
    1. Put your code in Java Tags. To do this, put [highlight=java] before your code and [/highlight] after your code.
    2. Give full details of errors and provide us with as much information about the situation as possible.
    3. Give us an example of what the output should look like when done correctly.

    Join the Airline Management Simulation Game to manage your own airline against other users in a virtual recreation of the United States Airline Industry. For more details, visit: http://airlinegame.orgfree.com/

Similar Threads

  1. Regarding Independent SIM Card
    By kalaicse30@gmail.com in forum What's Wrong With My Code?
    Replies: 0
    Last Post: October 4th, 2013, 12:31 AM
  2. Regarding Independent SIM Card
    By kalaicse30@gmail.com in forum What's Wrong With My Code?
    Replies: 0
    Last Post: October 4th, 2013, 12:29 AM
  3. Flatform Independent
    By harirock in forum What's Wrong With My Code?
    Replies: 2
    Last Post: November 20th, 2012, 03:39 PM
  4. Replies: 3
    Last Post: April 11th, 2011, 09:51 PM