学生信息管理系统beans,spring+hibernate配置

学生信息管理系统beans,spring+hibernate配置



<?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.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context.xsd
        http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">

<!-- <aop:aspectj-autoproxy/> -->
    <context:annotation-config/>
    <context:component-scan base-package="cn.jhc" />
    
    
    <bean name="logInterceptor" class="cn.jhc.aop.LogInterceptor" />
    
    <aop:config>
   <aop:aspect id="logAspect" ref="logInterceptor">
       <aop:pointcut id="myMethod"
           expression="execution (public * cn.jhc.service..*.add(..) )"/>
       <aop:before pointcut-ref="myMethod" method="before"/>
       <aop:around pointcut-ref="myMethod" method="aroundMethod"/>
   </aop:aspect>
</aop:config>
    
    
    <!-- Hibernate + spring -->
    
    <bean 
    class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="locations">
    <value>classpath:jdbc.properties</value>
    </property>
    </bean>
    
    
    
    <!-- 数据库连接, 配置数据源 -->
     <bean id="myDataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name="driverClassName" value="${jdbc.driverClass}"/>
   <property name="url" value="${jdbc.url}"/>
   <property name="username" value="root"/>
   <property name="password" value="1234"/>
    </bean>
    
    
    
    
    <bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
        <property name="dataSource" ref="myDataSource"/>
        <property name="annotatedClasses">
            <list>
                <value>cn.jhc.model.User</value>
                <value>cn.jhc.model.Student</value>
                <value>cn.jhc.model.Class</value>
                <value>cn.jhc.model.Score</value>
                <value>cn.jhc.model.Course</value>
               <!--  <value>cn.jhc.model.Log</value>  -->
            </list>
        </property>
        <property name="hibernateProperties">
            <value>
                hibernate.dialect=org.hibernate.dialect.MySQLDialect
                hibernate.current_session_context_class=thread
                hibernate.show_sql=true
                hibernate.hbm2ddl.auto=create
            </value>
        </property>
    </bean>
    
    <!-- 添加事务管理 ,声明事务管理器-->
    <bean id="txManager"
      class="org.springframework.orm.hibernate4.HibernateTransactionManager">
    <property name="sessionFactory" ref="sessionFactory" />
    </bean>
    <!--采用@Transactional注解方式使用事务  -->
    <tx:annotation-driven transaction-manager="txManager" />
    
    
    
    <!-- <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
   <property name="dataSource" ref="dataSource" />
   <property name="mappingResources">
       <list>
           <value>org/springframework/samples/petclinic/hibernate/petclinic.hbm.xml</value>
       </list>
   </property>
   <property name="hibernateProperties">
       <value>
           hibernate.dialect=${hibernate.dialect}
       </value>
   </property>
</bean>
-->


    
    
    
    
    
    
    <!--  <bean id="u" class="cn.jhc.dao.impl.UserDAOImpl" autowire="byName"/>
   
    <bean id="userService" class="cn.jhc.service.UserService"  scope="singleton" init-method="before">
     
    <property name="userDAO">
    <ref bean="u"/>
    </property>
     
    <constructor-arg index="0">
        <value>111</value>
    </constructor-arg>
     
    <constructor-arg index="1">
        <ref bean="u"></ref>
    </constructor-arg>
     
    <property name="list">
    <list>
            <value>1</value>
            <value>2</value>
            <value>3</value>
    </list>
    </property>
     
     
     
    <property name="set">
    <set>
            <value>3</value>
            <value>4</value>
            <value>5</value>
    </set>
    </property>
     
     
    <property name="map">
    <map>
            <entry key="num1" value="7"/>
            <entry key="num2" value="8"/>
    </map>
    </property>
        
        
     
     
    
    </bean>
     -->
    
    
    
</beans>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值