For example:
java -jar mySpringApplication --myJsonParameter="{\"myKey\":\"myValue\"}"
This should be resolved like that:
public class MyService {
@Autowired
//or @Value("myJsonParameter") ?
private MyInputDto myInputDto;
}
public class MyInputDto {
private String myKey;
}
The idea is to pass named parameter from command line (and following spring externalization practics) but inject Typed value parsed from json, not string.
You can try using property
spring.application.jsonand annotate yourMyInputDtoas@org.springframework.boot.context.properties.ConfigurationProperties.Start your application like this:
Implementing your service:
See Spring external configuration documentation for more information.