我正在與以下配置的春天啓動應用程序增加默認大小
@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,但無法讓它工作。