2016-11-10 112 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