想在aplicationContext.xml里配置两个db链接,启动Tomcat的时候就报错了
错误如下:
严重: Context initialization failed
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unexpected failure during bean definition parsing
Offending resource: class path resource [applicationContext.xml]
Bean 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Multiple 'property' definitions for property 'dataSource'
Offending resource: class path resource [applicationContext.xml]
Bean 'sqlSessionFactory'
-> Property 'dataSource'
at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:70)
aplicationContext.xml配置是:
<!-- DataSource1 -->
<bean id="dataSource1" class="org.apache.tomcat.dbcp.dbcp2.BasicDataSource" destroy-method="close">
<property name="url" value="jdbc:mysql://localhost:3306/facerecognitiondb"></property>
<property name="driverClassName" value="com.mysql.jdbc.Driver"></property>
<property name="username" value="ccg"></property>
<property name="password" value="111111"></property>
</bean>
<!-- DataSource2 -->
<bean id="dataSource2" class="org.apache.tomcat.dbcp.dbcp2.BasicDataSource" destroy-method="close">
<property name="url" value="jdbc:mysql://localhost:3306/faceserverdb"></property>
<property name="driverClassName" value="com.mysql.jdbc.Driver"></property>
<property name="username" value="ccg"></property>
<property name="password" value="111111"></property>
</bean>
<!--sqlSessionFactory -->
<!-- transactionManager -->
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<!-- enable transaction annotation support -->
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"
abstract="true">
PROPAGATION_REQUIRED
你是不是没有给sqlsessionFactory指定数据源啊?