shh结合碰到的一些想法
来源:互联网 发布:小型数据库管理系统 编辑:程序博客网 时间:2024/05/17 06:58
<?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:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
<!-- 公共配置项 -->
<!-- 1.1 加载properties文件 -->
<context:property-placeholder location="classpath:jdbcInfo.properties"/>
<!-- 1.2 配置数据源 -->
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="driverClass" value="${jdbc.driverClass}"></property>
<property name="jdbcUrl" value="${jdbc.jdbcUrl}"></property>
<property name="user" value="${jdbc.user}"></property>
<property name="password" value="${jdbc.password}"></property>
</bean>
<!-- 2. 配置SessionFactory -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"></property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.format_sql">true</prop>
</props>
</property>
<property name="mappingLocations" value="classpath:com/itheima/crm/*/domain/*.hbm.xml"></property>
</bean>
<!-- 3.事务管理 -->
<!-- 3.1 事务管理器 -->
<bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<!-- 3.2 事务详情
* 增删改:读写;查询:只读
-->
<tx:advice id="txAdvice" transaction-manager="txManager">
<tx:attributes>
<tx:method name="add*"/>
<tx:method name="update*"/>
<tx:method name="delete*"/>
<tx:method name="login" read-only="true"/>
<tx:method name="find*" read-only="true"/>
</tx:attributes>
</tx:advice>
<!-- 3.3 aop编程
* 强制cglib : proxy-target-class="true"
-->
<aop:config>
<aop:advisor advice-ref="txAdvice" pointcut="execution(* com.itheima.crm.*.service..*.*(..))"/>
</aop:config>
<!-- 4 导入其他配置文件 -->
<!-- 4.1 员工 -->
<import resource="applicationContext-staff.xml"/>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
<!-- 公共配置项 -->
<!-- 1.1 加载properties文件 -->
<context:property-placeholder location="classpath:jdbcInfo.properties"/>
<!-- 1.2 配置数据源 -->
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="driverClass" value="${jdbc.driverClass}"></property>
<property name="jdbcUrl" value="${jdbc.jdbcUrl}"></property>
<property name="user" value="${jdbc.user}"></property>
<property name="password" value="${jdbc.password}"></property>
</bean>
<!-- 2. 配置SessionFactory -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"></property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.format_sql">true</prop>
</props>
</property>
<property name="mappingLocations" value="classpath:com/itheima/crm/*/domain/*.hbm.xml"></property>
</bean>
<!-- 3.事务管理 -->
<!-- 3.1 事务管理器 -->
<bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<!-- 3.2 事务详情
* 增删改:读写;查询:只读
-->
<tx:advice id="txAdvice" transaction-manager="txManager">
<tx:attributes>
<tx:method name="add*"/>
<tx:method name="update*"/>
<tx:method name="delete*"/>
<tx:method name="login" read-only="true"/>
<tx:method name="find*" read-only="true"/>
</tx:attributes>
</tx:advice>
<!-- 3.3 aop编程
* 强制cglib : proxy-target-class="true"
-->
<aop:config>
<aop:advisor advice-ref="txAdvice" pointcut="execution(* com.itheima.crm.*.service..*.*(..))"/>
</aop:config>
<!-- 4 导入其他配置文件 -->
<!-- 4.1 员工 -->
<import resource="applicationContext-staff.xml"/>
</beans>
-------------------------------
1、这边的sessionFactory是直接把Hibernate.cfg.xml的 <session-factory></session-factory>移植过来,而且还需要有个<mapping resource="com/test/Student.hbm.xml" />。今天就是没加mapping报错了。
2、Service里面的那个待注入的dao,是需要用接口来的,如果用实现类的话就找不到方法,也是今天报错的主因。
0 0
- shh结合碰到的一些想法
- flex和eclipse结合的一些想法
- 碰到的一些错误
- 个人主页的一些想法
- 最近的一些想法
- 读书的一些想法
- 工作流的一些想法
- 一些杂乱的想法
- 单元测试的一些想法
- IEGroup 的一些想法
- 开发的一些想法
- 一些胡乱的想法
- 突然的一些想法
- 最近的一些想法
- AOP的一些想法
- 最近的一些想法
- 分页的一些想法
- TDD的一些想法
- SyntaxError: invalid syntax
- Action层, Service层 ,modle层 和 Dao层的功能区分
- Mac换源之Homebrew
- 【qscoj】喵哈哈村的代码传说 第二章 神经网络
- [转]VS中展开和折叠代码
- shh结合碰到的一些想法
- TCP/IP模型
- TypeError: '<' not supported between instances of 'str' and 'int'
- 阿里巴巴集团2017暑期实习Java研发工程师在线编程题-数组分片
- 自己研究写的一个弹幕库的功能
- Linux上部署Python3.6
- 用 hashcat 破解 WIFI WPA2破解思路
- IMWEB小白DAY3-制作个人名片
- IMWeb训练营作业-仿select组件