开发者

Java EE getting information about what environment the application is currently running

You can run a Java EE application in a test environment, a development environment or a production one.

How can I use Java code or XML to get hold of that information?

if ( ApplicationContext.inDevelopment() { // do this }

Obviously the above is not correct. But you get the point. How c开发者_高级运维an I do this?


there are many ways to achieve it.

  • check ip address of the sever to decide which platform it is running on.

  • add -D property into your server start script, in your program get
    the system property.

  • for different platforms using different properties files. each
    properties file contains a "platform" property

  • or if you are using maven to build your application, you can create
    profiles, to set property/attribute at building time.

...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜