我确信这是一个简单的配置问题,但我找不到它。当我在STS中运行我的java代码时
Spring Tool Suite
Version: 3.8.3.RELEASE
Build Id: 201612191457
Platform: Eclipse Mars.2 (4.5.2)
一切顺利。没有错误,没有问题。代码完成了应有的一切。
当我从命令行使用mvn包构建jar然后尝试运行它时,我得到:
2017-07-17 19:04:55,805 4523 ERROR com.zaxxer.hikari.pool.PoolBase - HikariPool-3 - Failed to execute isValid() for connection, co\
nfigure connection test query (com.ibm.db2.jcc.t4.b.isValid(I)Z).
Exception in thread "ThreadPoolTaskExecutor-1" 2017-07-17 19:04:55,807 4525 ERROR com.zaxxer.hikari.pool.PoolBase - HikariPool-2 -\
Failed to execute isValid() for connection, configure connection test query (com.ibm.db2.jcc.t4.b.isValid(I)Z).
2017-07-17 19:04:55,807 4525 ERROR com.zaxxer.hikari.pool.PoolBase - HikariPool-1 - Failed to execute isValid() for connection, co\
nfigure connection test query (com.ibm.db2.jcc.t4.b.isValid(I)Z).
2017-07-17 19:04:55,807 4525 ERROR com.zaxxer.hikari.pool.PoolBase - HikariPool-4 - Failed to execute isValid() for connection, co\
nfigure connection test query (com.ibm.db2.jcc.t4.b.isValid(I)Z).
Exception in thread "ThreadPoolTaskExecutor-1" Exception in thread "ThreadPoolTaskExecutor-1" Exception in thread "ThreadPoolTaskEx\
ecutor-1" java.lang.AbstractMethodError: com.ibm.db2.jcc.t4.b.isValid(I)Z
at com.zaxxer.hikari.pool.PoolBase.checkDriverSupport(PoolBase.java:434)
at com.zaxxer.hikari.pool.PoolBase.setupConnection(PoolBase.java:405)
at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:363)
at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:201)
我检查了所有我要检查的内容并且不知所措。我觉得这个必须是我错过的地方,但我找不到任何东西。
我的pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>GroupID</groupId>
<artifactId>ArtifactId</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<name>name</name>
<description>description</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.0.BUILD-SNAPSHOT</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-batch</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.ws</groupId>
<artifactId>spring-ws-core</artifactId>
</dependency>
<dependency>
<groupId>com.ibm.db2</groupId>
<artifactId>db2jcc</artifactId>
<version>10.5</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>20030203.000129</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure</artifactId>
</dependency>
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
</dependency>
<dependency>
<groupId>net.sf.opencsv</groupId>
<artifactId>opencsv</artifactId>
<version>2.3</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
<finalName>${project.artifactId}</finalName>
</build>
<repositories>
<repository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>1.4</version>
</dependency>
</dependencies>
</dependencyManagement>
</project>
答案 0 :(得分:1)
在JDBC 4.0中添加了isValid方法。
增加依赖性的问题:
<dependency>
<groupId>com.ibm.db2</groupId>
<artifactId>db2jcc</artifactId>
<version>10.5</version>
<scope>compile</scope>
</dependency>
你需要使用:
<dependency>
<groupId>com.ibm.db2.jcc</groupId>
<artifactId>db2jcc4</artifactId>
<version>10.1</version>
</dependency>