解决:java.lang.AbstractMethodError: null

解决:java.lang.AbstractMethodError: nullspringboot2.x整合sqlserver使用jtds连接池连数据库的时候出现异常2017-02-1512:12:23.955WARN14844—[main]ationConfigEmbeddedWebApplicationContext:Exceptionencounteredduringcontextinitializ…

大家好,又见面了,我是你们的朋友全栈君。

springboot 2.x 整合 sqlserver 使用 jtds连接池 连数据库的时候出现异常

2017-02-15 12:12:23.955  WARN 14844 --- [           main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is java.lang.AbstractMethodError
2017-02-15 12:12:23.964  INFO 14844 --- [           main] utoConfigurationReportLoggingInitializer :
Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2017-02-15 12:12:23.970 ERROR 14844 --- [           main] o.s.boot.SpringApplication               : Application startup failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is java.lang.AbstractMethodError
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1628) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1081) ~[spring-context-4.3.6.RELEASE.jar:4.3.6.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:856) ~[spring-context-4.3.6.RELEASE.jar:4.3.6.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:542) ~[spring-context-4.3.6.RELEASE.jar:4.3.6.RELEASE]
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.5.1.RELEASE.jar:1.5.1.RELEASE]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:737) [spring-boot-1.5.1.RELEASE.jar:1.5.1.RELEASE]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:370) [spring-boot-1.5.1.RELEASE.jar:1.5.1.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:314) [spring-boot-1.5.1.RELEASE.jar:1.5.1.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1162) [spring-boot-1.5.1.RELEASE.jar:1.5.1.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1151) [spring-boot-1.5.1.RELEASE.jar:1.5.1.RELEASE]
    at com.ingartek.ws.pps.PrestacionesPoliticasSocialesInternoApplication.main(PrestacionesPoliticasSocialesInternoApplication.java:26) [classes/:na]
Caused by: java.lang.AbstractMethodError: null
    at net.sourceforge.jtds.jdbc.JtdsConnection.isValid(JtdsConnection.java:2833) ~[jtds-1.3.1.jar:1.3.1]
    at com.zaxxer.hikari.pool.PoolBase.checkDriverSupport(PoolBase.java:422) ~[HikariCP-2.6.0.jar:na]
    at com.zaxxer.hikari.pool.PoolBase.setupConnection(PoolBase.java:393) ~[HikariCP-2.6.0.jar:na]
    at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:351) ~[HikariCP-2.6.0.jar:na]
    at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:196) ~[HikariCP-2.6.0.jar:na]
    at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:442) ~[HikariCP-2.6.0.jar:na]
    at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:505) ~[HikariCP-2.6.0.jar:na]
    at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:113) ~[HikariCP-2.6.0.jar:na]
    at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:97) ~[HikariCP-2.6.0.jar:na]
    at org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl.getConnection(DatasourceConnectionProviderImpl.java:122) ~[hibernate-core-5.2.6.Final.jar:5.2.6.Final]
    at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess.obtainConnection(JdbcEnvironmentInitiator.java:180) ~[hibernate-core-5.2.6.Final.jar:5.2.6.Final]
    at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:68) ~[hibernate-core-5.2.6.Final.jar:5.2.6.Final]
    at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:35) ~[hibernate-core-5.2.6.Final.jar:5.2.6.Final]
    at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:88) ~[hibernate-core-5.2.6.Final.jar:5.2.6.Final]
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:257) ~[hibernate-core-5.2.6.Final.jar:5.2.6.Final]
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:231) ~[hibernate-core-5.2.6.Final.jar:5.2.6.Final]
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:210) ~[hibernate-core-5.2.6.Final.jar:5.2.6.Final]
    at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:51) ~[hibernate-core-5.2.6.Final.jar:5.2.6.Final]
    at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:94) ~[hibernate-core-5.2.6.Final.jar:5.2.6.Final]
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:240) ~[hibernate-core-5.2.6.Final.jar:5.2.6.Final]
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:210) ~[hibernate-core-5.2.6.Final.jar:5.2.6.Final]
    at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.handleTypes(MetadataBuildingProcess.java:352) ~[hibernate-core-5.2.6.Final.jar:5.2.6.Final]
    at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:111) ~[hibernate-core-5.2.6.Final.jar:5.2.6.Final]
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.metadata(EntityManagerFactoryBuilderImpl.java:858) ~[hibernate-core-5.2.6.Final.jar:5.2.6.Final]
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:885) ~[hibernate-core-5.2.6.Final.jar:5.2.6.Final]
    at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:60) ~[spring-orm-4.3.6.RELEASE.jar:4.3.6.RELEASE]
    at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:353) ~[spring-orm-4.3.6.RELEASE.jar:4.3.6.RELEASE]
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:373) ~[spring-orm-4.3.6.RELEASE.jar:4.3.6.RELEASE]
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:362) ~[spring-orm-4.3.6.RELEASE.jar:4.3.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1687) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1624) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE]
    ... 16 common frames omitted

造成这个的根本原因是

net.sourceforge.jtds.jdbc.JtdsConnection没有实现,isValid因此您需要指定connection-test-query以确保isValid不调用该方法。application.yml文件中添加这个配置 

spring.datasource.hikari.connection-test-query=SELECT 1
spring:
  datasource:
    url: jdbc:jtds:sqlserver://localhost:5188/dbname
    username: root
    password: admin
    driver-class-name: net.sourceforge.jtds.jdbc.Driver
    hikari:
      connection-test-query:  SELECT 1

这样子就可以运行通过了,我使用的版本是

<dependency>
    <groupId>net.sourceforge.jtds</groupId>
    <artifactId>jtds</artifactId>
    <version>1.3.1</version>
</dependency>
<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.1.5.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>

参考博客: https://stackoverflow.com/questions/42247864/configure-hikaricp-in-spring-boot-with-jtds

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/136979.html原文链接:https://javaforall.cn

【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛

【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...

(3)


相关推荐

  • 【Custom Mutator Fuzz】AFL++自定义突变API「建议收藏」

    【Custom Mutator Fuzz】AFL++自定义突变API「建议收藏」前言其实这篇是临时加进来的,因为下一篇文章是libprotobuf+AFL++的内容,所以写的时候需要使用AFL++自定义突变的API,觉得还是需要单独写一篇API的介绍,一共十一个方法,也不是很多,下一篇文章就不再用大篇幅描述API了~编写不易,如果能够帮助到你,希望能够点赞收藏加关注哦Thanks♪(・ω・)ノPS:文章末尾有联系方式,交个朋友吧~本文链接:模糊测试系列往期回顾:【CustomMutatorFuzz】Libprotobuf+LibFuzzerCustomM.

  • 2020版Java视频教程|java零基础到就业全套视频教程线上免费观看,java免费教程直接看

    2020版Java视频教程|java零基础到就业全套视频教程线上免费观看,java免费教程直接看第一阶段:Java基础学习任何一门编程语言,首先要学习的是基础语法,开启Java学习的第一步,当然就是深入掌握计算机基础、编程基础语法,面向对象,集合、IO流、线程、并发、异常及网络编程,这些我们称之为JavaSE基础。当你掌握了这些内容之后,你就可以做出诸如:电脑上安装的迅雷下载软件、QQ聊天客户端、考勤管理系统等桌面端软件。第二阶段:数据库互联网最具价值的是数据,任何编程语言都需要解决数据存储问题,而数据存储的关键技术是数据库。MySQL和Oracle都是广受企业欢迎的数据库管理系统。Java

  • 京东云免费SLL正式(HTTPS)免费申请及nginx配置

    京东云免费SLL正式(HTTPS)免费申请及nginx配置京东云免费ssl证书申请及配置一、证书申请1、京东云地址:[https://www.jdcloud.com/](https://www.jdcloud.com/)2、登录京东云后可在左上角云服务中搜索:SSL3、选择搜索出的选项中的SSL数字证书,进入SSL证书管理平台;4、在左侧选择申购管理,然后点击申购证书5、在申购SSL证书界面,按下图选择对应的证书类型,即可购买;6、订单确认,立即支付即可完成证书的申请二、证书配置1、完善域名信息1、在申购管理中,找到刚才购买的证书,点击完善信息;2、在下面的输入

    2022年10月14日
  • Redirecting to /bin/systemctl start mysqld.service Failed to start mysqld.service: Unit not found.

    Redirecting to /bin/systemctl start mysqld.service Failed to start mysqld.service: Unit not found.为了在本地服务器下搭建svn,在CentOS中安装mysql,使用yuminstallmysql-servermysqlmysql-devel安装mysql却无法启动mysql服务使用servicemysqldstart在CentOS7中启动mysql报错:在提及该错误前,我们先提到一个mysql发展及当期背景:MySQL是一种开放源代码的关系型数据库管理系统(RDBMS………

  • 启动磁盘不能被分区或恢复成单个分区-解决了

    启动磁盘不能被分区或恢复成单个分区-解决了1,找到mac自带的“磁盘工具”。2,使用磁盘工具把多余的系统盘选择使用“抹掉”功能。3,抹掉磁盘选格式改为EXFAT格式。4,再一次使用BootCamp就可以恢复了。抹掉后,可以在磁盘分区中直接删除对应windows分区,这样就会合并为一个分区了,可以接着重新安装windows步骤参考文档:此文档少了上面的步骤,所以失败https://blog.csdn.net/weixin_35940949/article/details/112507403安装参考文档https://..

  • ArchLinux的使用(1):安装

    ArchLinux的使用(1):安装

发表回复

您的电子邮箱地址不会被公开。

关注全栈程序员社区公众号