我们正在为旧版应用程序使用wildfly 8.0版本。我们正在尝试将数据源值作为参数传递到standalone.xml文件中,但是wildfly由于无法识别$符号而引发错误。
standalone.xml
$ {DB_URL}
谁能解释如何在wildfly 8.0服务器中传递参数。我们正在将服务器作为服务启动。
服务Wildfly启动
这里是standalone.xml的代码段
<profile>
<subsystem xmlns="urn:jboss:domain:logging:2.0">
<subsystem xmlns="urn:jboss:domain:datasources:2.0">
<datasource jta="false" jndi-name="java:jboss/postgresDSPC" pool-name="postgresDSPC" enabled="true" use-java-context="true" use-ccm="false">
<connection-url>${DB_URL}</connection-url>
<driver>postgresql</driver>
<pool>
<min-pool-size>2</min-pool-size>
<max-pool-size>20</max-pool-size>
</pool>
<security>
<user-name>username</user-name>
<password>password</password>
</security>
<statement>
<prepared-statement-cache-size>50</prepared-statement-cache-size>
<share-prepared-statements>false</share-prepared-statements>
</statement>
</datasource>
</subsystem>
<subsystem xmlns="urn:jboss:domain:weld:2.0"/>
</profile>
这是我使用jboss-cli读取时看到的值
"connection-url" => {
"type" => STRING,
"description" => "The JDBC driver connection URL",
"expressions-allowed" => true,
"nillable" => false,
"min-length" => 1L,
"max-length" => 2147483647L,
"access-type" => "read-write",
"storage" => "configuration",
"restart-required" => "no-services"
},
谢谢Rakesh
对于环境变量,您将必须使用env。字首。例如
${env.DB_URL}