Announcement Announcement Module
No announcement yet.
RowMapper is not getting Autowired by Spring Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • RowMapper is not getting Autowired by Spring

    I have this configuration:
    <bean id="reader" class="" scope="prototype">
    	<property name="dataSource" ref="dataSource"/>
    	<property name="sql" value="select * from dummy"/>
    	<property name="rowMapper" ref="rowMapper"/>
    	<property name="verifyCursorPosition" value="false"/>
    <bean id="rowMapper" class=">
    	<property name="firstName" value="hillary/>
    MyRowMapper implements org.springframework.jdbc.core.RowMapper

    MyReader extends org.springframework.batch.item.database.JdbcCursor ItemReader

    Within MyReader, super.doRead() is called, and this returns MyRowMapper objects.
    However, these objects are not getting autowired by the container - the property firstName comes back as null. Note that MyReader is being autowired by the Spring container as expected.

    What needs to be done so that RowMapper is autowired?
    Thanks very much!
    Last edited by rosalie; Jul 4th, 2012, 10:23 AM.

  • #2
    I would expect a nice stacktrace if there wouldn't be a rowmapper so I would first check your rowmapper implementation, also be aware that you are injecting a singleton in a non singleton.

    Also the read method should return the objects created by the rowmapper implementation NOT rowmapper implementations.