admin 发表于 2014-6-2 14:20

三大框架(Struts+Spring+Hibernate)整合最新版(2014-6-2)

      /**
         * 三大框架整合,版本都是最新的
         * Spring 4.0.5   struts2.3.16.3Hibernate 4.3.5
         *数据库是mysql,JDK是1.6,Tomcat 7.0
         *使用了Hibernate注解,自动创建数据库和表,数据库是hehe,用户名和密码请自己修改
         *时间:2014-5-27
         *作者:男孩的天职
         *
         */
测试 spring:
      /**
         * 测试Spring是否整合成功
         * 同时要开启事务和提交事务
         * 整合之后的,不用开启,因为事务已经交给Spring了,所以可以注释掉开启事务和提交事务
         */
      public static void main(String[] args) {
      
                ApplicationContextapplicationContext=newClassPathXmlApplicationContext("applicationContext.xml");
      YhxxDaoyhxxDao=(YhxxDao)      applicationContext.getBean("yhxxDao");
                Yhxxyhxx=new Yhxx();
                yhxx.setId(2);//id=2要存在
      yhxxDao.deleteYhxx(yhxx);
      }测试hibernate:
/**
         * 测试Hiberante是否于数据库连接成功
         *
         */
      public static void main(String[] args) {
      
      
                Session session= HibernateUtil.getSession();
                System.out.println(session);

      }
整合资源下载:点击下载



跳蚤的约会 发表于 2014-6-4 14:28

谢谢分享,拿来试试,!!!!
页: [1]
查看完整版本: 三大框架(Struts+Spring+Hibernate)整合最新版(2014-6-2)