在commond line Spring Boot中传递多个参数。

问题描述 投票:0回答:1

我需要向maven命令行传递多个参数来运行spring boot应用程序。这就是我在spring boot中传递命令行参数的方法。我使用的是spring boot 2.2.6版本。

mvn spring-boot:run -Dspring-boot.run.arguments="--server.port=8999,--spring.application.instance_id=dhn"

但我得到以下错误信息

nested exception is org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under 'server.port' to java.lang.Integer

***************************
APPLICATION FAILED TO START
***************************

Description:

Failed to bind properties under 'server.port' to java.lang.Integer:

    Property: server.port
    Value: 8999,--spring.application.instance_id=dhn
    Origin: "server.port" from property source "commandLineArgs"
    Reason: failed to convert java.lang.String to java.lang.Integer

Action:

Update your application's configuration

似乎没有正确解析参数

java spring-boot maven command-line arguments
1个回答
0
投票

分隔符似乎不起作用。虽然我已经在教程中看到过这种风格。

工作原理是用空格作为分隔符。

mvn spring-boot:run -Dspring-boot.run.arguments="--server.port=8999 --spring.application.instance_id=dhn"
© www.soinside.com 2019 - 2024. All rights reserved.