Monday, September 30, 2013

Spring: Inject comma separated values into a List

1. Define your properties in a properties file

gestures=rock, paper, scissors, lizard, spock

2. Ensure that you have your context property placeholder defined in your context xml

<context:property-placeholder location="classpath*:*.properties"/>

3. Finally in your java class, you can inject the value when you define the class member:

 @Value("#{'${gestures}'.split(',')}")
 private List<String> gameGestures;


5 comments:

  1. Your blog has given me that thing which I never expect to get from all over the websites. Nice post guys!

    Melbourne SEO Services

    ReplyDelete
  2. I read this article. I think You put a lot of effort to create this article. I appreciate your work.
    thesis Writing Service

    ReplyDelete