摘要: 1.配置src/META-INF下persistence.xml注意文件名是固定的。 1 <?xml version="1.0" encoding="UTF-8"?> 2 <persistence xmlns="http://java.sun.com/xml/ns/persistence" 3 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 4 xsi:schemaLocation="http://java.sun.com/xm 阅读全文
posted @ 2011-12-28 10:40 tazi 阅读(970) 评论(0) 推荐(0) 编辑
摘要: 使用注解方式 1 package junit.test; 2 3 import static org.junit.Assert.*; 4 5 import org.junit.BeforeClass; 6 import org.junit.Test; 7 import org.springframework.context.ApplicationContext; 8 import org.springframework.context.support.ClassPathXmlApplicationContext; 9 10 import com.tazi.domin.Person;11 i.. 阅读全文
posted @ 2011-12-28 10:34 tazi 阅读(276) 评论(0) 推荐(0) 编辑
摘要: 加入context命名空间xmlns:context="http://www.springframework.org/schema/context"和xsi:schemaLocation中加上http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd然后使用<context:property-placeholder location="classpath:jdbc.properties&qu 阅读全文
posted @ 2011-12-28 10:30 tazi 阅读(262) 评论(0) 推荐(0) 编辑
摘要: 这里使用spring2.51.配置数据源2.配置Spring事务管理使用Spring的事务管理功能,则事务的开启、提交、回滚都不用手工进行。使用注解方式(推荐)或者使用xml方式。Spring提供了针对数据源的数据源事务管理器,1 <!-- 数据源事务管理器 -->2 <bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager" >3 <property name="dataSource&q 阅读全文
posted @ 2011-12-28 10:27 tazi 阅读(213) 评论(0) 推荐(0) 编辑