我需要向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
似乎没有正确解析参数
分隔符似乎不起作用。虽然我已经在教程中看到过这种风格。
工作原理是用空格作为分隔符。
mvn spring-boot:run -Dspring-boot.run.arguments="--server.port=8999 --spring.application.instance_id=dhn"