myibatis配置文件太多,springjdbc能夠輕量化切入,知足一個項目有2套機制spring
在spring配置文件加入:sql
<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate" abstract="false" lazy-init="false" autowire="default" > <property name="dataSource" ref="dataSource" /> </bean>
就能夠直接使用this
@Service public class Jxserivce implements IJxService { @Autowired private JdbcTemplate jdbcTemplate; public void setJdbcT(JdbcTemplate jdbcTemplate) { this.jdbcTemplate = jdbcTemplate; } public List findALL() { String sql = "select * from test_info"; List<Map<String, Object>> queryForList = jdbcTemplate.queryForList(sql); return queryForList; }