Spring的主配置文件applicationContext.xml
2018-01-07 01:27
387 查看
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="driverClass" value="oracle.jdbc.driver.OracleDriver" />
<property name="jdbcUrl" value="jdbc:oracle:thin:@127.0.0.1:1521:XE" />
<property name="user" value="itcast" />
<property name="password" value="itcast" />
</bean>
<!-- 2.sessionFactory-->
<bean id="sessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"></property>
<property name="configLocation" value="classpath:hibernate.cfg.xml"></property>
</bean>
<!-- 3.事务管理器-->
<bean id="transactionManager" class="org.springframework.orm.hibernate5.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<!-- 4.txAdvice-->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="save*"/>
<tx:method name="insert*"/>
<tx:method name="update*"/>
<tx:method name="delete*"/>
<tx:method name="get*" read-only="true"/>
<tx:method name="find*" read-only="true"/>
</tx:attributes>
</tx:advice>
<!-- 5.aop-->
<aop:config> bean(*Service)
<aop:pointcut id="pointcut" expression="execution(*
cn.itcast.jx.service.*Service.*(..))" />
<aop:advisor advice-ref="txAdvice" pointcut-ref="pointcut" />
</aop:config>
在Hibernate文件中进行如下配置:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="dialect">
org.hibernate.dialect.Oracle10gDialect
</property>
<property name="show_sql">true</property>
<property name="format_sql">false</property>
<property name="hbm2ddl.auto">update</property>
<!--校验模式 JPA java persistent api-->
<property name="javax.persistence.validation.mode">none</property>
</session-factory>
</hibernate-configuration>
<property name="driverClass" value="oracle.jdbc.driver.OracleDriver" />
<property name="jdbcUrl" value="jdbc:oracle:thin:@127.0.0.1:1521:XE" />
<property name="user" value="itcast" />
<property name="password" value="itcast" />
</bean>
<!-- 2.sessionFactory-->
<bean id="sessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"></property>
<property name="configLocation" value="classpath:hibernate.cfg.xml"></property>
</bean>
<!-- 3.事务管理器-->
<bean id="transactionManager" class="org.springframework.orm.hibernate5.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<!-- 4.txAdvice-->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="save*"/>
<tx:method name="insert*"/>
<tx:method name="update*"/>
<tx:method name="delete*"/>
<tx:method name="get*" read-only="true"/>
<tx:method name="find*" read-only="true"/>
</tx:attributes>
</tx:advice>
<!-- 5.aop-->
<aop:config> bean(*Service)
<aop:pointcut id="pointcut" expression="execution(*
cn.itcast.jx.service.*Service.*(..))" />
<aop:advisor advice-ref="txAdvice" pointcut-ref="pointcut" />
</aop:config>
在Hibernate文件中进行如下配置:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="dialect">
org.hibernate.dialect.Oracle10gDialect
</property>
<property name="show_sql">true</property>
<property name="format_sql">false</property>
<property name="hbm2ddl.auto">update</property>
<!--校验模式 JPA java persistent api-->
<property name="javax.persistence.validation.mode">none</property>
</session-factory>
</hibernate-configuration>
相关文章推荐
- Spring 配置文件applicationContext.xml的切割原则
- applicationContext.xml import spring模块配置文件
- 要想看懂 spring 的配置文件:ApplicationContext.xml 第一步
- Spring配置文件总结-applicationContext.xml
- Hibernate SQL方言 (hibernate.dialect) Spring配置文件applicationContext.xml
- spring applicationContext.xml的配置文件详解
- applicationContext.xml文件中怎么配置struts2和spring配置文件的加载路径
- Spring中,applicationContext.xml 配置文件在web.xml中的配置详解
- Spring 框架的 applicationContext.xml 配置文件
- Hibernate SQL方言 (hibernate.dialect) Spring配置文件applicationContext.xml
- Spring配置文件的applicationContext.xml文件头部出现红叉
- Spring配置文件(applicationContext.xml如何配置)
- Hibernate与Spring整合,配置文件applicationContext.xml
- spring ApplicationContext.xml之多个配置文件结合
- 【SpringMVC之配置文件(一)】spring 里面的ApplicationContext.xml 和 xxx-servlet.xml分别的作用是什么?
- spring applicationContext.xml的配置文件详解
- spring配置文件ApplicationContext.xml里面class等没有提示功能
- 服务器运行的状态,修改Spring中的applicationContext.xml配置文件
- Spring配置文件applicationContext.xml 找不到的问题
- spring applicationContext.xml 配置文件 详解