2016-11-10 114 views
-1

我正在與以下配置的春天啓動應用程序增加默認大小

@ConfigurationProperties(prefix= "app.sample") 
    @Component 
    public class PropGenerator{ 

     private List<String> list; 

     public List<String> getList() { 
      return list; 
     } 
     public void setList(List<String> list) { 
      this.list = list; 
     } 
} 

application.properties以格式配置如下

app.sample.list 300項[0] =值1 。 。

app.sample.list [299] = value300

當我運行程序時,我得到下面的錯誤

Invalid list index in property path 'list[279]'; nested exception is java.lang.IndexOutOfBoundsException: Index: 279, Size: 251 
Caused by: java.lang.IndexOutOfBoundsException: Index: 279, Size: 251 

我如何可以手動覆蓋列表的大小,讓所有300值將自動填充在list變量中?我遇到@InitBinder,但無法讓它工作。

回答

0

當我們必須在Spring Boot 1.3.7中更改限制時(參見#6436),我們會自動增長集合。根據您當前使用的版本,升級應該修復它。如果沒有,請創建一個能夠重現問題並創建問題的樣本in the Spring Boot issue tracker