Spring整理

Bean配置

1. <context:component-scan base-package="com.test" />这个包下的Spring注解才有效

属性文件自动解析

<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" id="propertyConfigurer">
<property name="locations">
<list>
<value>classpath*:app.properties</value>
</list>
</property>
<property name="fileEncoding" value="utf-8" />
</bean>

Spring事务

<!-- Transaction manager for JPA -->
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory"/>
<property name="globalRollbackOnParticipationFailure" value="false" /><!--解决嵌套事务导致的事务回滚 -->
</bean>

<!-- Transaction manager for JPA -->
<tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true" />
<jpa:repositories base-package="com.test" entity-manager-factory-ref="entityManagerFactory" transaction-manager-ref="transactionManager" />

原文地址:https://www.cnblogs.com/warmingsun/p/5715490.html