Spring learning_annotationとトランザクション

1.アノテーションを使用してメソッドをすべて成功または失敗させる

jarパッケージ
トランザクション:spring-> lib-> spring-tx-4.3.10.RELEASE .jar
データベース:ojdbc .jar
データソース:commons-dbcp-1.4 .jar
接続プール:commons-pool.jar
springJDBC:spring-jdbc -4.3.10.RELEASE .jar
AOP:aopalliance-1.0 .jar
もちろん、IDEAを使用している場合、これらを使用する必要はありません。hahahahaConfigure
Spring

    <!--配置数据库相关-->
    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
        <property name="driverClassName" value="oracle.jdbc.OracleDriver"/>
        <property name="url" value="jdbc:oracle:thin:@127.0.0.1:1521:xe"/>
        <property name="username" value="hr"/>
        <property name="password" value="hr"/>
    </bean>

    <!--配置事务管理器-->
    <bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
        <property name="dataSource" ref="dataSource">

        </property>
    </bean>

    <!--增加对事务的支持-->
    <tx:annotation-driven transaction-manager="txManager"/>
     <bean id="personDao" class="com.itheima.dao.PersonDaoImpl">

    </bean>
    <bean id="studentServicesImpl" class="com.itheima.service.PersonServiceImpl">
        <property name="personDao" ref="personDao">

        </property>
    </bean>

ここに画像の説明を挿入

心が花や木のように

おすすめ

転載: blog.csdn.net/nbcsdn/article/details/98983400