简体   繁体   English

如何外部化standalone.xml?

[英]How to externalize standalone.xml?

I am setting up a new server and want to externalize standalone.xml configuration mainly datasource to the properties file so that it can be configured using a properties file. 我正在设置一个新服务器,并希望将standalone.xml配置主要是数据源外部化到属性文件,以便可以使用属性文件进行配置。 I have used various options like using -P properties flag, still no use. 我已经使用了各种选项,例如使用-P properties标志,仍然没有用。 I am using wildfly 10.0 Final. 我正在使用wildfly 10.0 Final。 for example from this 例如从这里

<connection-url>jdbc:postgresql://localhost:5432/local_db?currentSchema=something</connection-url>

to this 对此

<connection-url>${connection_url}</connection-url>

To in JBoss you could create a properties file and execute a cli command to read it, for example, creating your datasource. 在JBoss中,您可以创建一个属性文件并执行cli命令来读取它,例如,创建数据源。

File 文件

Example of datasource property file: 数据源属性文件的示例:

set ds=TestDB
set dsName=java:jboss/datasources/$ds
data-source add --name=$ds --jndi-name=$dsName --driver-name=example \
    --connection-url="jdbc:example"\
    --user-name="exampleuser"  --password="examplepassword"
echo 'Success'
reload

That can be saved as "file.txt" 可以另存为“ file.txt”

File command 文件命令

Then execute the following cli command: 然后执行以下cli命令:

./jboss-cli.sh --connect --file="file.txt"

Regarding Escape sequence 关于转义序列

Be careful regarding the escape sequence, because it changes for the CLI according to the configuration of JBoss and the flag resolve-paramater-values, which if it's set to true tells the CLI to interpret $ instead of just passing it to EAP as is and consequently the escape sequence for --file changes to /$/$. 请注意转义序列,因为它会根据JBoss的配置和标志resolve-paramater-values的变化而改变CLI,如果将其设置为true,则告诉CLI解释$而不是直接将其传递给EAP和因此,--file的转义序列更改为/ $ / $。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM