SSH Web Demo Spring 配置 AOP

来源:互联网 发布:组策略禁止安装软件 编辑:程序博客网 时间:2024/06/03 13:27

最近闲来没事 最近封装了一下SSH框架 的一些配置 但具体原来还在理解当中 包括横切面 点切 事物管理的配置
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"      destroy-method="close">    <property name="driverClass" value="com.mysql.jdbc.Driver"/>    <property name="jdbcUrl" value="jdbc:mysql://127.0.0.1:3306/test"/>    <property name="user" value="root"/>    <property name="password" value="123456"/>    <property name="minPoolSize" value="10"/>    <!--连接池中保留的最大连接数。Default: 15 -->    <property name="maxPoolSize" value="100"/>    <!--最大空闲时间,1800秒内未使用则连接被丢弃。若为0则永不丢弃。Default: 0 -->    <property name="maxIdleTime" value="60"/>    <!--当连接池中的连接耗尽的时候c3p0一次同时获取的连接数。Default: 3 -->    <property name="acquireIncrement" value="3"/>    <property name="maxStatements" value="1000"/>    <property name="initialPoolSize" value="10"/>    <!--每60秒检查所有连接池中的空闲连接。Default: 0 -->    <property name="idleConnectionTestPeriod" value="30"/>    <!--定义在从数据库获取新连接失败后重复尝试的次数。Default: 30 -->    <property name="acquireRetryAttempts" value="30"/>    <property name="breakAfterAcquireFailure" value="true"/>    <property name="testConnectionOnCheckout" value="false"/></bean>

<bean id="hibernateTransactionManager"      class="org.springframework.orm.hibernate4.HibernateTransactionManager">    <property name="sessionFactory" ref="sessionFactory"/></bean><!-- 配置事务管理器 --><bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">    <property name="dataSource" ref="dataSource"></property></bean><!-- 配置事务通知 --><tx:advice id="txAdvice" transaction-manager="txManager">    <tx:attributes>        <tx:method name="add*" propagation="REQUIRED"/>        <tx:method name="insert*" propagation="REQUIRED"/>        <tx:method name="update*" propagation="REQUIRED"/>        <tx:method name="delete*" propagation="REQUIRED" />        <tx:method name="select*" read-only="true"/>        <tx:method name="find*" read-only="true"/>        <tx:method name="get*" read-only="true"/>        <tx:method name="query*" read-only="true"/>    </tx:attributes></tx:advice><!-- 配置aop --><aop:config proxy-target-class="true">    <aop:pointcut expression="execution(* com.demo.Service..*(..))" id="pointcut"/>    <aop:advisor advice-ref="txAdvice" pointcut-ref="pointcut"/></aop:config><bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">    <property name="dataSource">        <ref bean="dataSource"/>    </property>    <property name="annotatedClasses">        <list>            <value>com.demo.Entity.Detai</value>            <value>com.demo.Entity.Student</value>            <value>com.demo.Entity.Users</value>        </list>    </property>
    这里会有问题 下面有注释    <property name="hibernateProperties">        <props>            <prop key="dialect">org.hibernate.dialect.MySQLDialect</prop>            <prop key="hibernate.show_sql">true</prop>            <prop key="hibernate.format_sql">true</prop>            <prop key="hibernate.hbm2ddl.auto">update</prop>            <!--添加此句报异常:            在spring的类LocalSessionFactoryBean源码,            方法buildSessionFactory中将hibernate.current_session_context_class设为org.springframework.orm.hibernate5.SpringSessionContext            <prop key="hibernate.current_session_context_class">thread</prop>             -->            <prop key="hibernate.current_session_context_class">org.springframework.orm.hibernate5.SpringSessionContext</prop>        </props>    </property></bean>
hibernate4.0 有很多不支持。。封装的时候会出现各种classnotfound的问题 
具体是添加一个 aspectjweaver.jar 的包 才将错误改掉


写得超级简单 demo就不上传了。主要记录一下是怎么配置成功的。