package cn.outofmemory.hellspring.transaction; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport; import org.springframework.stereotype.Repository; import com.ibatis.sqlmap.client.SqlMapClient; @Repository public class CustomerDao extends SqlMapClientDaoSupport { @Autowired(required = true) public CustomerDao(@Qualifier(value="sqlMapClient4A") SqlMapClient sqlMapClient) { super.setSqlMapClient(sqlMapClient); } }
注意Qualifier的位置必须放在参数的前面,而不能放在构造函数的前面。 这是合理的如果一个构造函数有多个参数的话把Qualifier放在构造函数前面就会有歧义。