了解基于XML、注解的声明式AspectJ开发案例代码的编写,了解 Spring JDBC 的配置,了解Spring JdbcTemplate 的常用方法,了解基于XML方式和基于Annotation方式的声明式事务管理的实现。
controller类
package gsg.controller;
import javax.annotation.Resource;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import gsg.service.AccountService;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("classpath:applicationContext.xml")
public class AccountController {
@Resource(name="accountService")
private AccountService accountService;
@Test
public void demo1(){
accountService.insertaccount("张三", 100000d);
System.out.println("存款成功");
}
@Test
public void demo2(){
accountService.transfer("张三", "张二", 2d);
System.out.println("转账成功");
}
@Test
public void demo3(){
accountService.insertaccount("张六", 100000d);
accountService.transfer("张56", "张5", 1d);
System.out.println("转账失败");} }
dao类
package gsg.dao;
public interface AccountDao {
public void insertaccount(String name, Double money);
public String findaccount(String name);
public void outMoney(String from ,Double money);
public void inMoney(String to ,Double money);
}
package gsg.dao;
import java.sql.ResultSet;
import java.sql.SQLException;
import org