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

查看:18
本文介绍了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天全站免登陆