我尝试使用 JBoss PowerShell 客户端将模块添加到 WildFly 实例,但当模块的路径包含空格时失败。
我尝试将路径用单引号和双引号括起来,但没有成功。
<小时/>测试用例列表:
- 不带引号
- 使用单引号
- 使用双引号
- 使用反斜杠转义空格 (
\
) - 使用反引号 (`) 转义空格
- 在单引号命令中使用双引号
- 使用反引号 (`) 转义内部双引号
- 使用反斜杠转义内部双引号 (
\
) - 使用双引号 (
""
) - 在双引号命令中使用反斜杠 (
\
) 转义内部单引号
示例
1。不带引号
JBoss 客户端命令
.\jboss-cli.ps1 --connect --command="module add --name=mssql.jdbc --resources=C:/module directory/sqljdbc42.jar"
错误消息
<小时/>The command accepts 1 unnamed argument(s) but received: [add, directory/sqljdbc42.jar]
2。使用单引号
JBoss 客户端命令
.\jboss-cli.ps1 --connect --command="module add --name=mssql.jdbc --resources='C:/module directory/sqljdbc42.jar'"
错误消息
<小时/>The command accepts 1 unnamed argument(s) but received: [add, directory/sqljdbc42.jar']
3。使用双引号
JBoss 客户端命令
.\jboss-cli.ps1 --connect --command="module add --name=mssql.jdbc --resources="C:/module directory/sqljdbc42.jar""
错误消息
<小时/>'directory\sqljdbc42.jar' is assumed to be a command(s) but the commands to execute have been specified by another argument: [module add --name=mssql.jdbc --resources=C:\module]
4。使用反斜杠转义空格 (\
)
JBoss 客户端命令
.\jboss-cli.ps1 --connect --command="module add --name=mssql.jdbc --resources=C:/module\ directory/sqljdbc42.jar
错误消息
<小时/>Failed to locate C:\module\ directory\sqljdbc42.jar, if you defined a nonexistent resource on purpose you should use the --allow-nonexistent-resources option
5。使用反引号 (`) 转义空格
.\jboss-cli.ps1 --connect --command="module add --name=mssql.jdbc --resources=C:/module` directory/sqljdbc42.jar"
错误消息
<小时/>The command accepts 1 unnamed argument(s) but received: [add, directory/sqljdbc42.jar]
6。在单引号命令中使用双引号
JBoss 客户端命令
.\jboss-cli.ps1 --connect --command='module add --name=mssql.jdbc --resources="C:/module directory/sqljdbc42.jar"'
错误消息
<小时/>'directory/sqljdbc42.jar' is assumed to be a command(s) but the commands to execute have been specified by another argument: [module add --name=mssql.jdbc --resources=C:/module]
7。使用反引号 (`) 转义内部双引号
JBoss 客户端命令
.\jboss-cli.ps1 --connect --command="module add --name=mssql.jdbc --resources=`"C:/module directory/sqljdbc42.jar`""
错误消息
<小时/>'directory/sqljdbc42.jar' is assumed to be a command(s) but the commands to execute have been specified by another argument: [module add --name=mssql.jdbc --resources=C:/module]
8。使用反斜杠转义内部双引号 (\
)
JBoss 客户端命令
.\jboss-cli.ps1 --connect --command="module add --name=mssql.jdbc --resources=\"C:/module directory/sqljdbc42.jar\""
错误消息
<小时/>'directory/sqljdbc42.jar\' is assumed to be a command(s) but the commands to execute have been specified by another argument: [module add --name=mssql.jdbc --resources=\C:/module]
9。使用双双引号 (""
)
JBoss 客户端命令
.\jboss-cli.ps1 --connect --command="module add --name=mssql.jdbc --resources=""C:/module directory/sqljdbc42.jar"""
错误消息
<小时/>'directory/sqljdbc42.jar' is assumed to be a command(s) but the commands to execute have been specified by another argument: [module add --name=mssql.jdbc --resources=C:/module]
10。在双引号命令中使用反斜杠 (\
) 转义内部单引号
JBoss 客户端命令
.\jboss-cli.ps1 --connect --command="module add --name=mssql.jdbc --resources=\'C:/module directory/sqljdbc42.jar\'"
错误消息
The command accepts 1 unnamed argument(s) but received: [add, 'C:/module, directory/sqljdbc42.jar\']
最佳答案
正确的格式是在单引号命令中转义双引号。
.\jboss-cli.ps1 --connect --command='module add --name=mssql.jdbc --resources=\"C:/module directory/sqljdbc42.jar\"'
感谢@Aaron 的帮助。
关于java - JBoss PowerShell 客户端添加带有空格的模块路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59738094/