【问题标题】:Wildfly 8.0 Passing parameters to standalone.xml fileWildfly 8.0 将参数传递给standalone.xml 文件
【发布时间】: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 上的环境变量。

标签: jboss wildfly wildfly-8


【解决方案1】:

对于环境变量,您必须使用 env.字首。例如

${env.DB_URL} 

【讨论】:

  • 非常感谢您的帮助。似乎当我们以 .如果我使用所有其他参数运行 ./standalone.sh -D ,“service wildfly start”似乎不起作用。
  • 它不适用于“环境”。字首?使用 -D 参数设置 (Java) SystemParameters。它们与您前面提到的(OS)环境参数不同。要在standalone.xml 中引用环境参数,请使用“env。”前缀应该可以工作。
  • 谢谢,所以您可以考虑通过单击答案左侧的复选标记来关闭您的问题。
猜你喜欢
  • 2020-11-07
  • 2011-01-12
  • 2013-06-30
  • 1970-01-01
  • 2019-03-18
  • 1970-01-01
  • 2014-02-03
  • 2014-05-25
  • 2021-12-08
相关资源
最近更新 更多