沒有添加事務管理的依賴
java.lang.NoClassDefFoundError: org/springframework/dao/support/DaoSupport:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>${spring.version}</version>
</dependency>
連接池注入錯誤
Caused by: org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'dataSource' threw exception; nested exception is java.lang.NoClassDefFoundError: org/springframework/jdbc/datasource/TransactionAwareDataSourceProxy
沒有配置jdbc依賴
NoClassDefFoundError: org/springframework/jdbc/datasource/TransactionAwareDataSourceProxy
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${spring.version}</version>
</dependency>
配置文件路徑寫錯
expected at least 1 bean which qualifies as autowire candidate for this depe
@ContextConfiguration(locations = "classpath*:spring/applicationContext*.xml")
這裏寫錯了
測試類中加載不到配置文件
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):
路徑正確,idea中將resources目錄標記爲ResourcesBoot導致,修改爲TestResourcesBoot後正常
連接池屬性注入失敗
service層注入也加載了properties文件,<value>classpath:resources/*.properties</value>這一段配置與placeholder衝突,修改爲
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath*:resources/*.properties</value>
</list>
</property>
</bean>