gpt4 book ai didi

java - 在 STS 中运行的代码没有问题,但从命令行运行时崩溃

转载 作者:行者123 更新时间:2023-12-02 12:34:47 26 4
gpt4 key购买 nike

我确信这是某种简单的配置问题,但我找不到它。当我在 STS 中运行 java 代码时

Spring Tool Suite 

Version: 3.8.3.RELEASE
Build Id: 201612191457
Platform: Eclipse Mars.2 (4.5.2)

一切运行良好。没有错误,没有问题。该代码做了它应该做的一切。

当我从命令行使用 mvn package 构建 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)

我已经检查了我所知道的所有检查,但不知所措。我觉得这一定是我错过的某个build设置,但我找不到任何东西。

我的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>

最佳答案

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>

关于java - 在 STS 中运行的代码没有问题,但从命令行运行时崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45173353/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com