ZK+spring+hbernate




<?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:p="http://www.springframework.org/schema/p"
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/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">

<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName" value="com.mysql.jdbc.Driver"></property>
<property name="url" value="jdbc:mysql://127.0.0.1:3306/xhblog?useUnicode=true&amp;characterEncoding=UTF-8"></property>
<property name="username" value="root"></property>
<property name="password" value="111111"></property>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.hbm2ddl.auto">update</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.format_sql">true</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>com/xh/blog/model/Admin.hbm.xml</value>
<value>com/xh/blog/model/Blog.hbm.xml</value>
<value>com/xh/blog/model/Category.hbm.xml</value>
<value>com/xh/blog/model/Comment.hbm.xml</value>

</list>
</property>

</bean>
<bean id="adminDao" class="com.xh.blog.dao.hibernate.AdminDaoHibernate">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<bean id="blogDao" class="com.xh.blog.dao.hibernate.BlogDaoHibernate">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<bean id="categoryDao" class="com.xh.blog.dao.hibernate.CategoryDaoHibernate">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>

<bean id="commentDao" class="com.xh.blog.dao.hibernate.CommentDaoHibernate">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<bean id="adminManager" class="com.xh.blog.service.impl.AdminManagerImpl">
<property name="adminDao">
<ref bean="adminDao" />
</property>
</bean>
<bean id="blogManager" class="com.xh.blog.service.impl.BlogManagerImpl">
<property name="blogDao">
<ref bean="blogDao" />
</property>
</bean>
<bean id="categoryManager" class="com.xh.blog.service.impl.CategoryManagerImpl">
<property name="categoryDao">
<ref bean="categoryDao" />
</property>
</bean>
<bean id="commentManager" class="com.xh.blog.service.impl.CommentManagerImpl">
<property name="commentDao">
<ref bean="commentDao" />
</property>
</bean>

<bean id="adminBean" class="com.xh.blog.web.zk.AdminZk"
scope="prototype">
<property name="adminManager">
<ref bean="adminManager" />
</property>
</bean>
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref local="sessionFactory" />
</property>
</bean>
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="save*" propagation="REQUIRED" />
<tx:method name="delete*" propagation="REQUIRED" />
<tx:method name="update*" propagation="REQUIRED" />
<tx:method name="find*" propagation="REQUIRED" />
<tx:method name="*" read-only="true" />
</tx:attributes>
</tx:advice>
<aop:config>
<aop:pointcut id="allManagerMethod"
expression="execution (* com.xh.blog.service.*.*(..))" />
<aop:advisor advice-ref="txAdvice" pointcut-ref="allManagerMethod" />
</aop:config>
</beans>

你可能感兴趣的:(spring,xml,Hibernate,Blog,zk)