Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Passing multiple arguments in command line Spring Boot

I need to pass multiple arguments to maven command line to run a spring boot application. This is how I was passing command line arguments in spring boot. I am using spring boot 2.2.6 Release

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

However I get the following error

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

Seems like the arguments are not parsed correctly

like image 209
Rajmohan P Avatar asked Aug 28 '26 15:08

Rajmohan P


1 Answers

The , separator seems not to work. Although I already saw this style in tutorials.

What works is a space as seprator:

mvn spring-boot:run -Dspring-boot.run.arguments="--server.port=8999 --spring.application.instance_id=dhn"
like image 110
Simon Martinelli Avatar answered Aug 30 '26 06:08

Simon Martinelli



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!