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

  • RowMapper is not getting Autowired by Spring

    I have this configuration:
    Code:
    <bean id="reader" class="com.company.MyReader" 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>
    
    <bean id="rowMapper" class="com.company.MyRowMapper>
    	<property name="firstName" value="hillary/>
    </bean>
    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, 11: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.

    Comment

    Working...
    X