JBoss数据源中的环境变量 [英] Environment variables in JBoss datasource

查看:138
本文介绍了JBoss数据源中的环境变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个正在运行的JBoss服务器,想要部署服务. 该服务将连接到在以下xml文件中配置的数据库

I have a JBoss server running and want to deploy a service. The service connects to a database which is configured in the following xml file

<?xml version="1.0" encoding="UTF-8"?>
<datasources xmlns="http://www.jboss.org/ironjacamar/schema">
    <datasource jta="false" jndi-name="java:/PMBootStrapDS"
        pool-name="PMBootStrapDS" enabled="true" use-ccm="false">
        <connection-url>jdbc:postgresql://localhost:5432/i2b2</connection-url>
        <driver-class>org.postgresql.Driver</driver-class>
        <driver>postgresql-9.2-1002.jdbc4.jar</driver>
        <security>
            <user-name>i2b2pm</user-name>
            <password>demouser</password>
        </security>
        <validation>
            <validate-on-match>false</validate-on-match>
            <background-validation>false</background-validation>
        </validation>
        <statement>
            <share-prepared-statements>false</share-prepared-statements>
        </statement>
    </datasource>
</datasources>

要轻松地将其部署在不同的系统上,我想将数据库位置绑定到环境变量. 我尝试过这样的事情

To deploy it on different systems easily, I want to bind the database location to an environment variable. I tried something like this

<connection-url>jdbc:postgresql://${env.MY_DB_LOCATION}/i2b2</connection-url>

但它不起作用.

关于如何解决此问题的任何建议?

Any suggestions on how to solve this issue?

推荐答案

请确保您在standalone.xml中启用了属性替换.

Make sure you have property substitution enabled in your standalone.xml.

在standalone.xml中查找以下子系统,并确保将值设置为true

Look for the following subsytem in standalone.xml, and make sure the values are set to true

<subsystem xmlns="urn:jboss:domain:ee:1.1">
     <spec-descriptor-property-replacement>true</spec-descriptor-property-replacement>
     <jboss-descriptor-property-replacement>true</jboss-descriptor-property-replacement>
</subsystem>

仅eap6和jboss 7.1.2(或更高版本)支持此功能

This is only supported for eap6 and jboss 7.1.2 (or later)

这篇关于JBoss数据源中的环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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