`
yufenfei
  • 浏览: 798646 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

重温搭建Spring2.5+Hibernate3.3框架

阅读更多

    好久没有搭建SSH框架了,今天偶然搭建,感到生疏,都忘了需要哪些JAR包,今天在这总结一下

    Spring2.5+Hibernate3.3

 

1.使用spring2.5.6必须至少使用两个Jar

    spring.jar

    lib\jakarta-commons\commons-logging.jar

 

 

2.使用Hibernate3必须使用的Jar

   hibernate3.jar

   lib\required下所有Jar

   还需要slf4j-api-1.5.0.jar的实现包slf4j-log4j12-1.5.0.jar与log4j-1.2.15.jar

  slf4j-api-1.5.0.jar与slf4j-log4j12-1.5.0.jar版本应该是一致的,slf4j-log4j12-1.5.0.jar此包spring2.5.6提供的有

 

3.如果想使用spring的注解,则需要加入\lib\j2ee\common-annotations.jar

 

4.如果hibernate使用注解要加载配置文件,则需要下载hibernate-annotations-3.4.0.GA,添加hibernate-annotations.jar、\lib\ejb3-persistence.jar和\lib\hibernate-commons-annotations.jar

 

5.不要忘了数据库驱动Jar

 

 

<context-param>
    <param-name>contextConfigLocation</param-name>
 <param-value>
   /WEB-INF/applicationContext-*.xml
 </param-value>
</context-param>

<listener>
  <listener-class>
     org.springframework.web.context.ContextLoaderListener
  </listener-class>
</listener>

 

 

 

 

 

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
           http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
           http://www.springframework.org/schema/context
           http://www.springframework.org/schema/context/spring-context-2.5.xsd
           http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
           http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">

  <context:component-scan base-package="com.wch.dao,com.wch.service" />
     
       
   <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
         <property name="driverClassName" value="com.microsoft.jdbc.sqlserver.SQLServerDriver"/>
         <property name="url" value="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=acegi;SelectMethod=cursor"/>
         <property name="username" value="sa"/>
         <property name="password" value="server"/>
   </bean>
 
 <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
    <property name="dataSource" ref="dataSource"></property>
    <property name="packagesToScan" value="com/wch/entity/"></property>
 </bean>
 <bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
    <property name="sessionFactory" ref="sessionFactory"></property>
 </bean>
 <tx:annotation-driven transaction-manager="txManager"/>
</beans>

 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics