title: How to define and read array of objects from spring's application.properties?
body: <p>In my Java class, I want to read a variable that will give me a list of tokens in one shot and my token is an object with fields as name, value, and enabled.</p>
  <pre><code>@Value(&quot;authorised_applications&quot;)
  private List&lt;Token&gt; tokenList;
  </code></pre>
  <p>How do I define this in my application.properties file so that I can read all tokens at once.
  For an instance, I have tokens like:</p>
  <pre><code>token1
  - value: 123456,
  - name: specialToken,
  - enabled: true
  
  token2
  - value: 56173,
  - name: newToken,
  - enabled: false
  </code></pre>
  <p>I have tried other links but could not find a way to read this all at once.</p>
  <p>Want to create bean like this</p>
  <pre><code>@ConfigurationProperties(&quot;authorised&quot;)
  @Configuration
  public class AppTokenConfiguration {
      private final List&lt;TokenStore.Token&gt; tokenList = new ArrayList&lt;&gt;();
  
      @Bean
      public TokenStore getTokenStore() {
          return new TokenStore(tokenList.stream().collect(Collectors.toMap(TokenStore.Token::getToken, Function.identity())));
      }
  }
  
  </code></pre>