5
回答
找不到方法:java.lang.NoSuchMethodError: com.mysql.jdbc.jdbc2.optional.MysqlXAConnection.<init>(Lcom/mysql/jdbc/ConnectionImpl;Z)V

请教大家

<bean id="investors_dataSource" class="com.alibaba.druid.pool.xa.DruidXADataSource" init-method="init" destroy-method="close">

      <!-- 基本属性 url、user、password -->

      <property name="url" value="${jdbc.investors.url}" />

      <property name="username" value="${jdbc.username}" />

      <property name="password" value="${jdbc.password}" />


      <!-- 配置初始化大小、最小、最大 -->

      <property name="initialSize" value="${jdbc.initialSize}" />

      <property name="minIdle" value="${jdbc.maxIdle}" />

      <property name="maxActive" value="${jdbc.maxActive}" />


      <!-- 配置获取连接等待超时的时间 -->

      <property name="maxWait" value="${jdbc.maxWait}" />


      <!-- 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 -->

      <property name="timeBetweenEvictionRunsMillis" value="60000" />


      <!-- 配置一个连接在池中最小生存的时间,单位是毫秒 -->

      <property name="minEvictableIdleTimeMillis" value="300000" />


      <!-- 测试有效用的SQL Query -->

      <property name="validationQuery" value="SELECT 'x'" />

      <!-- 连接空闲时测试是否有效 -->

      <property name="testWhileIdle" value="true" />

      <!-- 获取连接时测试是否有效 -->

      <property name="testOnBorrow" value="true" />

      <!-- 归还连接时是否测试有效 -->

      <property name="testOnReturn" value="true" />


      <!-- 打开PSCache,并且指定每个连接上PSCache的大小

  分库分表较多的数据库,建议配置为false -->

      <property name="poolPreparedStatements" value="false" />

      <property name="maxPoolPreparedStatementPerConnectionSize" value="20" />


      <!-- 定期把监控数据输出到日志中 -->

      <!-- <property name="timeBetweenLogStatsMillis" value="300000" /> -->


      <property name="proxyFilters">

        <list>

        <!-- 配置监控统计拦截的filters -->

            <ref bean="stat-filter" />

        </list>

      </property>

</bean>


<bean id="trans_dataSource" class="com.alibaba.druid.pool.xa.DruidXADataSource" init-method="init" destroy-method="close">

      <!-- 基本属性 url、user、password -->

      <property name="url" value="${jdbc.trans.url}" />

      <property name="username" value="${jdbc.username}" />

      <property name="password" value="${jdbc.password}" />


      <!-- 配置初始化大小、最小、最大 -->

      <property name="initialSize" value="${jdbc.initialSize}" />

      <property name="minIdle" value="${jdbc.maxIdle}" />

      <property name="maxActive" value="${jdbc.maxActive}" />


      <!-- 配置获取连接等待超时的时间 -->

      <property name="maxWait" value="${jdbc.maxWait}" />


      <!-- 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 -->

      <property name="timeBetweenEvictionRunsMillis" value="60000" />


      <!-- 配置一个连接在池中最小生存的时间,单位是毫秒 -->

      <property name="minEvictableIdleTimeMillis" value="300000" />


      <!-- 测试有效用的SQL Query -->

      <property name="validationQuery" value="SELECT 'x'" />

      <!-- 连接空闲时测试是否有效 -->

      <property name="testWhileIdle" value="true" />

      <!-- 获取连接时测试是否有效 -->

      <property name="testOnBorrow" value="true" />

      <!-- 归还连接时是否测试有效 -->

      <property name="testOnReturn" value="true" />


      <!-- 打开PSCache,并且指定每个连接上PSCache的大小

  分库分表较多的数据库,建议配置为false -->

      <property name="poolPreparedStatements" value="false" />

      <property name="maxPoolPreparedStatementPerConnectionSize" value="20" />


      <!-- 定期把监控数据输出到日志中 -->

      <!-- <property name="timeBetweenLogStatsMillis" value="300000" /> -->


      <property name="proxyFilters">

        <list>

        <!-- 配置监控统计拦截的filters -->

            <ref bean="stat-filter" />

        </list>

      </property>

</bean>

<bean id="investorsDataSource" class="com.atomikos.jdbc.AtomikosDataSourceBean" init-method="init" destroy-method="close">

        <property name="uniqueResourceName" value="investorsDS"/> 

        <property name="xaDataSource">      

            <ref bean="investors_dataSource"/>

        </property>  

</bean>

<bean id="transDataSource" class="com.atomikos.jdbc.AtomikosDataSourceBean" init-method="init" destroy-method="close">

        <property name="uniqueResourceName" value="transDS"/> 

        <property name="xaDataSource">      

            <ref bean="trans_dataSource"/>

        </property>  

</bean>

<bean id="investorSqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean" scope="prototype">

<property name="dataSource" ref="investorsDataSource" />

<property name="plugins">

<list>

<ref bean="pageInterceptor" />

</list>

</property>

        <property name="mapperLocations" value="classpath:fmappers/user/*.xml" />

</bean>

Caused by: java.lang.NoSuchMethodError: com.mysql.jdbc.jdbc2.optional.MysqlXAConnection.<init>(Lcom/mysql/jdbc/ConnectionImpl;Z)V

at com.alibaba.druid.util.MySqlUtils.createXAConnection(MySqlUtils.java:40)

at com.alibaba.druid.pool.xa.DruidXADataSource.createPhysicalXAConnection(DruidXADataSource.java:72)

at com.alibaba.druid.pool.xa.DruidXADataSource.getXAConnection(DruidXADataSource.java:48)

at com.atomikos.jdbc.AtomikosXAConnectionFactory.createPooledConnection(AtomikosXAConnectionFactory.java:60)

at com.atomikos.datasource.pool.ConnectionPool.createPooledConnection(ConnectionPool.java:116)

at com.atomikos.datasource.pool.ConnectionPool.addConnectionsIfMinPoolSizeNotReached(ConnectionPool.java:104)

at com.atomikos.datasource.pool.ConnectionPool.init(ConnectionPool.java:78)

at com.atomikos.datasource.pool.ConnectionPool.<init>(ConnectionPool.java:67)

at com.atomikos.jdbc.AbstractDataSourceBean.init(AbstractDataSourceBean.java:297)

at com.atomikos.jdbc.AbstractDataSourceBean.getConnection(AbstractDataSourceBean.java:339)

at com.atomikos.jdbc.AbstractDataSourceBean.getConnection(AbstractDataSourceBean.java:394)

at org.apache.ibatis.mapping.VendorDatabaseIdProvider.getDatabaseProductName(VendorDatabaseIdProvider.java:82)

at org.apache.ibatis.mapping.VendorDatabaseIdProvider.getDatabaseName(VendorDatabaseIdProvider.java:66)

at org.apache.ibatis.mapping.VendorDatabaseIdProvider.getDatabaseId(VendorDatabaseIdProvider.java:53)

at org.mybatis.spring.SqlSessionFactoryBean.buildSqlSessionFactory(SqlSessionFactoryBean.java:445)

at org.mybatis.spring.SqlSessionFactoryBean.afterPropertiesSet(SqlSessionFactoryBean.java:336)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1612)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1549)

... 47 more

举报
Kevin郑
发帖于2年前 5回/1K+阅
顶部