![Spring整理 Spring整理](https://image.shishitao.com:8440/aHR0cHM6Ly9ia3FzaW1nLmlrYWZhbi5jb20vdXBsb2FkL2NoYXRncHQtcy5wbmc%2FIQ%3D%3D.png?!?w=700&webp=1)
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" />