【发布时间】:2020-01-19 16:28:48
【问题描述】:
我们正在为旧版应用程序使用 Wildfly 8.0 版本。我们正在尝试在standalone.xml 文件中将数据源值作为参数传递,但wildfly 抛出错误,因为它无法识别$ 符号。
独立的.xml
${DB_URL}
谁能解释如何在wildfly 8.0 服务器中传递参数。我们正在将我们的服务器作为服务启动。
服务 Wildfly 启动
这里是standalone.xml的sn-p
<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"
},
谢谢 拉克什
【问题讨论】:
-
standalone.xml 中的相关部分如何?确切的错误信息是什么?基本上并非所有模块都支持使用 ${...} 语法的属性解析。数据源应该可以正常工作。您可以使用 cli 进行检查:read-resource-description(recursive=true) 查找“表达式允许”标志。
-
这是错误。 ${DB_URL}" 2020-01-19 04:40:54,249 错误 [org.jboss.as.controller.management-operation](控制器引导线程)JBAS014613:操作(“添加”)失败 -
-
确定属性设置了吗?你是怎么设置的? (再一次:standalone.xml 中的部分看起来如何)
-
附加了standalone.xml sn-p。我们将属性设置为 shell 上的环境变量。