<?
xml
version
=
"1.0"
encoding
=
"UTF-8"
?>
<
beans
xmlns
=
"http://www.springframework.org/schema/beans"
xmlns:context
=
"http://www.springframework.org/schema/context"
xmlns:xsi
=
"http://www.w3.org/2001/XMLSchema-instance"
xmlns:tx
=
"http://www.springframework.org/schema/tx"
xmlns:aop
=
"http://www.springframework.org/schema/aop"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-4.0.xsd ">
<
bean
id
=
"myHibTxManager"
class
=
"org.springframework.orm.hibernate5.HibernateTransactionManager"
>
<
property
name
=
"sessionFactory"
ref
=
"sessionFactory"
/>
</
bean
>
<
tx:advice
id
=
"tx_Advice"
transaction-manager
=
"myHibTxManager"
>
<
tx:attributes
>
<
tx:method
name
=
"get*"
propagation
=
"SUPPORTS"
read-only
=
"true"
/>
<
tx:method
name
=
"load*"
propagation
=
"SUPPORTS"
read-only
=
"true"
/>
<
tx:method
name
=
"search*"
propagation
=
"SUPPORTS"
read-only
=
"true"
/>
<
tx:method
name
=
"*"
propagation
=
"REQUIRED"
/>
</
tx:attributes
>
</
tx:advice
>
<
aop:config
>
<
aop:pointcut
id
=
"bizMethods"
expression
=
"execution(* cn.zifangsky.service.*.*(..))"
/>
<
aop:advisor
advice-ref
=
"tx_Advice"
pointcut-ref
=
"bizMethods"
/>
</
aop:config
>
<
bean
id
=
"dataSource"
class
=
"org.springframework.jdbc.datasource.DriverManagerDataSource"
>
<
property
name
=
"driverClassName"
value
=
"com.mysql.jdbc.Driver"
/>
<
property
name
=
"url"
value
=
"jdbc:mysql://127.0.0.1/zxpm"
/>
<
property
name
=
"username"
value
=
"root"
/>
<
property
name
=
"password"
value
=
"root"
/>
</
bean
>
<
bean
id
=
"sessionFactory"
class
=
"org.springframework.orm.hibernate5.LocalSessionFactoryBean"
>
<
property
name
=
"dataSource"
ref
=
"dataSource"
/>
<
property
name
=
"packagesToScan"
>
<
list
>
<
value
>cn.zifangsky.entity</
value
>
</
list
>
</
property
>
<
property
name
=
"hibernateProperties"
>
<
props
>
<
prop
key
=
"hibernate.show_sql"
>true</
prop
>
</
props
>
</
property
>
</
bean
>
</
beans
>