学生信息管理系统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>