1, web.xml中配置spring监听类

  

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

 

2,需要一个struts2-spring-plugin.jar

3,srping整合hibernate  配置数据库连接  Session工厂

     

  <!-- 配置数据连接类 -->      
    <bean >  
        <property name="driverClassName"  
            value="org.gjt.mm.mysql.Driver">  
        </property>  
        <property name="url" value="jdbc:mysql://localhost:3306/hibernate"></property> 
        <property name="username" value="root"></property>
        <property name="password" value="1"></property>  
   </bean>  
 
   
 <!-- 配置session工厂类 -->      
    <bean > 
        <property name="dataSource">  
            <ref bean="dataSource" />  
        </property>  
        <property name="hibernateProperties">  
            <props>  
                <prop key="hibernate.dialect">  
                    org.hibernate.dialect.MySQLDialect   
                </prop>  
                <prop key="hibernate.show_sql">true</prop>  
            </props>  
        </property>  
        <property name="mappingResources">  
          <value>org/it/po/User.hbm.xml</value>  
        </property>  
     </bean> 

注:只是一些简单 大概流程  只供忘记时参考.

   

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-05-29
  • 2022-12-23
  • 2021-09-16
  • 2022-01-12
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-05-27
  • 2021-07-08
  • 2021-08-27
  • 2022-12-23
  • 2022-02-15
相关资源
相似解决方案