79289669

Date: 2024-12-18 00:20:33
Score: 2
Natty:
Report link

As mentioned in the comment by @JavaSheriff, there seems to be no escaping the no-escaping of commas. So I did a hacky little workaround, by taking advantage of Spring's @PostConstruct annotation, like so:

// the field into which I want to inject values
@Value("${my.application.property}")
private List<String> props;

// an extra field to hold the comma-containing value
@Value("${other.prop}")
private List<String> otherProps;

@PostContruct
private void fixArgs() {
  // re-constitute values with commas
  String collectedArgs = String.join(",", otherProps);
  props.add(collectedArgs);
}

The @PostConstruct annotation causes the method to be run after the bean has been instantiated and the values injected.

Reasons:
  • RegEx Blacklisted phrase (1): I want
  • Long answer (-0.5):
  • Has code block (-0.5):
  • User mentioned (1): @JavaSheriff
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: Tomás Gray