Skip to main content
AI Assist is now on Stack Overflow. Start a chat to get instant answers from across the network. Sign up to save and share your chats.
added 9 characters in body
Source Link

The Answer

@Value("#{'${my.list.of.strings}'.split(',')}") private List<String> myList; 

works as expected for the comma separated values. To handle null  (when property not specified) added the default value(': 'after': 'after the property name) as empty string as below @Value("#{'${my.list.of.strings: }'.split(',')}")

@Value("#{'${my.list.of.strings: }'.split(',')}") 

The Answer

@Value("#{'${my.list.of.strings}'.split(',')}") private List<String> myList; 

works as expected for the comma separated values. To handle null(when property not specified) added the default value(': 'after the property name) as empty string as below @Value("#{'${my.list.of.strings: }'.split(',')}")

The Answer

@Value("#{'${my.list.of.strings}'.split(',')}") private List<String> myList; 

works as expected for the comma separated values. To handle null  (when property not specified) added the default value(': 'after the property name) as empty string as below:

@Value("#{'${my.list.of.strings: }'.split(',')}") 
Source Link

The Answer

@Value("#{'${my.list.of.strings}'.split(',')}") private List<String> myList; 

works as expected for the comma separated values. To handle null(when property not specified) added the default value(': 'after the property name) as empty string as below @Value("#{'${my.list.of.strings: }'.split(',')}")