您的位置:首页 > 编程语言 > Java开发

05(maven+SSH)网上商城项目实战之spring mybatis整合

2015-11-11 16:08 671 查看
1.配置POM.xml文件 ,配置项目所需jar2.配置WEB.xml:配置spring监听器
3.创建anotation.xml配置文件<!-- spring扫描 @service -->
4. 创建jdbc.properties和jdbc.xml,并配置:
5.配置property.xml文件,读取JDBC配置
6.配置mybatis.xml文件
7.事务管理transation.xml:
8.UserInfoDAO.xml
9.事务管理注释:@Transactionalimport org.springframework.beans.factory.annotation.Autowired;import org.springframework.stereotype.Service;import org.springframework.transaction.annotation.Transactional;import cn.liu.croe.bean.UserInfo;import cn.liu.croe.dao.UserInfoDAO;import cn.liu.croe.service.IUserInfoService;@Service@Transactionalpublic class UserInfoServiceImpl implements IUserInfoService {@Autowiredprivate UserInfoDAO userdao;public void addUser(UserInfo user) {int i = userdao.add(user);System.out.println(i);throw new RuntimeException("运行时异常");}}10.测试类:
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  maven 电商 java