简体   繁体   中英

Play framework 1.2.4 war environemnt specific configuration file

Is there a way to include environment specific properties or configuration file while building war.

QA

entity.url=http://qa.test..

prod

entity.url=http://prod...

I need to make around 5 to 6 REST calls. Url is different for each environment. Hence is there any way to configure environment specific conf file?

thanks in advance

The Play Framework has the concept of 'ids' that can be used for different modes see here: http://www.playframework.org/documentation/1.2.4/ids

This allows you to do:

%qa.entity.url=http://qa.test..
%prod.entity.url=http://qa.test..

The one thing that might not be clear by their documentation is how to set this in a war. When running as a .war file, the play ID is set to 'war' by default. This can be changed in the web.xml of the .war file. You can do that or you can specify the ID when you create the war:

play war -o PATH --%prod

Not that I am aware of (and reading the python source for building the war does not indicate this is available). The war file simply builds up your Play application, as is. If you want to have a different configuration, then this may simply require the loading of it from an external resource (a property file that lives outside of the WAR, that you ship with your WAR file).

Alternatively, you could modify the python script that builds the WAR file to custom add additional properties to your file. Look in the directory framework/pym/commands/ and look at the war.py to read the source for the python war command.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM