有没有办法在Websphere中传递应用程序特定的属性? [英] Is there a way to pass application specific properties in Websphere?

查看:86
本文介绍了有没有办法在Websphere中传递应用程序特定的属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个Websphere应用程序服务器,其中部署了多个应用程序.所有应用程序都使用相同的属性(键),但具有不同的值.例如 : spring.profiles.active =在一个应用程序中测试,spring.profiles.active = UAT在其他应用程序中. 是否可以在Websphere启动期间将这些不同的值传递给应用程序?

We have a websphere application server where multiple applications are deployed. All applications use a common property(Key) but have different Value. For example : spring.profiles.active=test in one application, spring.profiles.active=UAT in some other application. Is it possible to pass these different values to the applications during start-up in Websphere ?

如果我们在通用JVM参数"文本框中的JVM选项中设置这些值,那么对于我们不需要的所有应用程序,这些值都将变为相同.

If we set these values in JVM options in the Generic JVM Arguments text box then it will become same for all the applications which we don't want.

在Websphere的应用程序级别设置这些属性,以便在启动应用程序时- 对于应用程序1-spring.profiles.active = test 对于应用程序2-spring.profiles.active = UAT

Set these properties at application level in websphere so that when applications are started - For application 1 - spring.profiles.active=test For application 2 - spring.profiles.active=UAT

推荐答案

此文件指示您可以在每个Web应用程序的WebApplicationInitializer中设置spring.profiles.active属性.然后,每个应用程序都可以从系统属性中读取其自己的专门命名的属性.或者,如果使用Liberty(在传统的WebSphere与Liberty之间未指定问题),则可以使用MicroProfile Config定义一个属性,该属性的通用名称通过appProperty对于每个应用程序都有不同的定义,例如,如此知识中心文章 .但是您仍然需要WebApplicationInitializer来

This document indicates that you can set the spring.profiles.active property in a WebApplicationInitializer per web application. Each application could then read its own specifically named property from System properties. Alternatively if using Liberty (the question didn't specify between traditional WebSphere vs Liberty), then you could use MicroProfile Config to define a property with a common name that is defined differently per application via appProperties, for example as shown in this knowledge center article. But you would still need the WebApplicationInitializer to read the value from MicroProfile Config.

示例如下:

Config config = ConfigProvider.getConfig();
servletContext.setInitParameter(
    "spring.profiles.active",
    config.getValue("ProfilesActive", String.class));

server.xml:

server.xml:

<server>
  <featureManager>
    <feature>mpConfig-1.3</feature>
    .. other features
  </featureManager>

  <application location="app1.war">
    <appProperties>
      <property name="ProfilesActive" value="test"/>
    </appProperties>    
  </application>

  <application location="app2.war">
    <appProperties>
      <property name="ProfilesActive" value="UAT"/>
    </appProperties>    
  </application>
</server>

这篇关于有没有办法在Websphere中传递应用程序特定的属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆