Struts2.1.8+Spring2.5.6+Hibernate3.6.8框架搭建+

2026/4/27 0:34:06

控制数据源内加载的PreparedStatements数量。 如果maxStatements与

maxStatementsPerConnection均为0,则缓存被关闭。Default: 0 -->

name=\value=\

value=\y>

---------------------- jdbc.properties配置文件的内容 ------------------------ jdbcUrl = jdbc:mysql:///itcastoa

driverClass = com.mysql.jdbc.Driver username = root password = 1234 2、测试代码 SpringTest.java

private ApplicationContext ac = new

ClassPathXmlApplicationContext( \ontext.xml\

@Test// 测试 SessionFactory 的配置 public void testSessionFactory(){

SessionFactory sessionFactory = (SessionFactory) ac.getBean(\

Assert.assertNotNull(sessionFactory.openSession()); }

2、配置声明式事务(使用基于注解的方式) 1、配置

class=\ernateTransactionManager\

transaction-manager=\ 2、测试代码 1、Service类 @Service

public class InsertUserService { @Resource

private SessionFactory sessionFactory; @Transactional

public void addUsers() {

sessionFactory.getCurrentSession().save(new User());

// int a = 1 / 0; // 这行会抛异常

sessionFactory.getCurrentSession().save(new User()); } }

2、单元测试


Struts2.1.8+Spring2.5.6+Hibernate3.6.8框架搭建.doc 将本文的Word文档下载到电脑
搜索更多关于: Struts2.1.8+Spring2.5.6+Hibern 的文档
相关推荐
相关阅读
× 游客快捷下载通道(下载后可以自由复制和排版)

下载本文档需要支付 10

支付方式:

开通VIP包月会员 特价:29元/月

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:xuecool-com QQ:370150219