日期:2014-05-16  浏览次数:20540 次

spring jdbcTemplate使用
关于java.lang.IllegalArgumentException: 'dataSource' or 'jdbcTemplate' is required 类似问题的解决总结:http://www.cnblogs.com/MoShin/archive/2011/10/10/2204020.html

参考:
spring jdbcTemplate使用http://log-cd.iteye.com/blog/215059
Spring JdbcTemplate 与 事务管理 学习 http://www.iteye.com/topic/480432

SimpleJdbcTemplate在spring3.1已经过时了,我就改为使用jdbcTemplate和namedParameterJdbcOperations写sql查询
* @deprecated since Spring 3.1 in favor of {@link org.springframework.jdbc.core.JdbcTemplate} and
* {@link org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate}. The JdbcTemplate and
* NamedParameterJdbcTemplate now provide all the functionality of the SimpleJdbcTemplate.

Spring NamedParameterJdbcTemplate 详解 : http://blog.csdn.net/dyllove98/article/details/7772470



pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<groupId>com.pandy</groupId>
	<artifactId>ssjdbc</artifactId>
	<packaging>war</packaging>
	<version>0.0.1-SNAPSHOT</version>
	<name>ssm3 Maven Webapp</name>
	<url>http://maven.apache.org</url>
	<properties>
		<spring.version>3.2.1.RELEASE</spring.version>
		<spring.jdbc.version>3.2.1.RELEASE</spring.jdbc.version>
		<aspectj.version>1.6.10</aspectj.version>
		<jetty.version>6.1.26</jetty.version>
		<tomcat.version>2.1-SNAPSHOT</tomcat.version>
		<junit.version>3.8.1</junit.version>
		<mysql.version>5.1.23</mysql.version>
		<jtds.version>1.2.4</jtds.version>
		<cglib.version>2.2.2</cglib.version>
	</properties>

	<dependencies>
		<dependency>
			<groupId>junit</groupId>
			<artifactId>junit</artifactId>
			<version>${junit.version}</version>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-core</artifactId>
			<version>${spring.version}</version>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-web</artifactId>
			<version>${spring.version}</version>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-webmvc</artifactId>
			<version>${spring.version}</version>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-beans</artifactId>
			<version>${spring.version}</version>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-context</artifactId>
			<version>${spring.version}</version>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-aop</artifactId>
			<version>${spring.version}</version>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-tx</artifactId>
			<version>${spring.version}</version>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-orm</artifactId>
			<version>${spring.version}</version>
		</dependency>

		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-jdbc</artifactId>
			<version>${spring.jdbc.version}</version&