- 創建屬性試圖自動映射字段集使用Java anotations只有在項目
在下面的失敗域對象:Spring Batch的使用Java註釋java.lang.IllegalStateException:不能沒有元數據
BeanWrapperFieldSetMapper.mapFieldSet
( (第187行):binder.bind(new MutablePropertyValues(getBeanProperties(copy, fs.getProperties()))); @Override public Properties getProperties() { if (names == null) { throw new IllegalStateException("Cannot create properties without meta data"); }
注:我沒有指定名稱,因爲我試圖自動映射。
以下是我的代碼:
@Bean public LineMapper<Partner> lineMapper() { DefaultLineMapper<Partner> lineMapper = new DefaultLineMapper<Partner>(); DelimitedLineTokenizer lineTokenizer = new DelimitedLineTokenizer(); BeanWrapperFieldSetMapper<Partner> fieldSetMapper = new BeanWrapperFieldSetMapper<Partner>(); fieldSetMapper.setBeanFactory(getApplicationContext()); fieldSetMapper.setTargetType(Partner.class); lineMapper.setLineTokenizer(lineTokenizer); lineMapper.setFieldSetMapper(fieldSetMapper); return lineMapper; }
精確的堆棧跟蹤
退出,DESCR。 :
org.springframework.batch.item.file.FlatFileParseException: Parsing error at line: 1 in resource=[class path resource [partner-import.csv]], input=[Mustermann,Max,[email protected],m]
產生的原因:
java.lang.IllegalStateException: Cannot create properties without meta data at org.springframework.batch.item.file.transform.DefaultFieldSet.getProperties(DefaultFieldSet.java:745)
4
A
回答
1
你缺少設置likeTokenizer.setNames()是因爲您名字的時候我試圖自動映射(您Partner
屬性的名稱)
相關問題
- 1. 有沒有人知道如何在「元註釋」中使用Spring的ImportResource註釋?
- 2. 使用Spring Web Mvc沒有註釋是可能的嗎?
- 3. Spring MVC 3.1沒有註釋?
- 4. 瞭解spring xml註釋元數據?
- 5. 使用Spring的元註釋擴展lombok註釋
- 6. 使用批註的Spring集成和Spring批處理[Spring-Batch-Integration]
- 7. 使用Java Spring 3.0 @NumberFormat註釋
- 8. 有沒有在包級別使用Spring @Profile註釋的方法?
- 9. 沒有註釋的Spring驗證框架
- 10. java.lang.IllegalStateException:找不到WebApplicationContext:沒有ContextLoaderListener註冊?
- 11. 找不到WebApplicationContext:沒有ContextLoaderListener註冊:java.lang.IllegalStateException
- 12. Java註釋:使用Anotations更改數據
- 13. 是否有可能不使用數據註釋屬性ServiceStack OrmLite?
- 14. 微風元數據不能拾取EF數據註釋
- 15. 的Java:運行Spring Batch的
- 16. 有關在Java/Spring中使用註釋的資源
- 17. 沒有使用Spring註釋獲取jdbcTemplate的實例
- 18. Java Spring註釋錯誤
- 19. WNY我收到 「java.lang.IllegalStateException:沒有TransactionalEventListener標註」?
- 20. 使用Spring Batch ItemReader讀取的行數
- 21. 休眠註釋元數據
- 22. 使用Java註釋
- 23. 有用的Java註釋
- 24. 使用Spring MVC 3.0和@EJB註釋而沒有mappedName?
- 25. 使用元數據的自定義數據註釋屬性
- 26. JUnit Spring with xml沒有註釋未能加載bean
- 27. 使用Spring雲配置java.lang.IllegalStateException:沒有git的
- 28. JAXB生成沒有註釋的java類
- 29. 是否有可能將Spring MVC與Jersey註釋一起使用?
- 30. 使用SpringData設置沒有bean註釋的2個數據庫時出錯
,請參閱6.6.2.7 。將字段自動映射到來自批處理的域對象 我不應該要求指定名稱。 – explorer 2014-10-29 23:23:51
您是否將標題名稱放入csv文件? – 2014-10-30 06:14:55
是的,我有第一條記錄作爲合作伙伴bean中的確切列名。 – explorer 2014-10-30 21:10:52