Java NoClassDefFoundError:com/google/cloud/kms/v1/KeyManagementServiceClient
我是第一次在这里写信,所以如果我要补充更多的问题,我很抱歉。我正在用java创建一个应用程序,并试图在Google云上创建KeyManagementServiceClient连接。程序构建正确,但是当我运行下面的函数时,我收到与com/google/cloud/kms/v1/KeyManagementServiceClient相关的NoClassDefFound错误Java NoClassDefFoundError:com/google/cloud/kms/v1/KeyManagementServiceClient,java,maven,google-cloud-platform,google-cloud-kms,Java,Maven,Google Cloud Platform,Google Cloud Kms,我是第一次在这里写信,所以如果我要补充更多的问题,我很抱歉。我正在用java创建一个应用程序,并试图在Google云上创建KeyManagementServiceClient连接。程序构建正确,但是当我运行下面的函数时,我收到与com/google/cloud/kms/v1/KeyManagementServiceClient相关的NoClassDefFound错误 try (KeyManagementServiceClient client = KeyManagementServiceClie
try (KeyManagementServiceClient client = KeyManagementServiceClient.create())
我使用的是maven,我对这个问题的所有研究都让我觉得我的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>com.mycompany.app</groupId>
<artifactId>encryptiontobucket</artifactId>
<version>1.0-SNAPSHOT</version>
<name>my-app</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-kms-bom</artifactId>
<version>1.40.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-kms</artifactId>
</dependency>
</dependencies>
<build>
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
</plugin>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.0.0</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
要安装客户端库,请查看下面的链接 如果您使用的是Maven,请将以下内容添加到pom.xml文件中
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>libraries-bom</artifactId>
<version>9.1.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-kms</artifactId>
</dependency>
</dependencies>
com.google.cloud
库bom表
9.1.0
聚甲醛
进口
com.google.cloud
谷歌云kms
要安装客户端库,请查看下面的链接
如果您使用的是Maven,请将以下内容添加到pom.xml文件中
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>libraries-bom</artifactId>
<version>9.1.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-kms</artifactId>
</dependency>
</dependencies>
com.google.cloud
库bom表
9.1.0
聚甲醛
进口
com.google.cloud
谷歌云kms
我已经复制了你的pom.xml并构建了它,它可以正常工作。请分享更多详细信息。构建不是错误。我的java代码使用了一系列java swing函数,这些函数都运行良好,但只要命令try(KeyManagementServiceClient=KeyManagementServiceClient.create())
(无论有没有try/catch,它都会给我这个错误。我会分享你的代码。我的代码现在已经被分享了。你需要用完整的类路径运行你的jar,否则像这样的库将不可用。我已经复制了你的pom.xml并构建了它,它可以正常工作。请分享更多细节。构建不是错误。我的java代码使用了bun所有java swing函数都可以正常运行,但只要命令try(KeyManagementServiceClient=KeyManagementServiceClient.create())
(无论有没有try/catch,它都会给我这个错误。我将共享你的代码。我的代码现在已经被共享了。你需要用完整的类路径运行你的jar,否则类似的库将不可用。如果不幸运地将它添加到pom.xml,我仍然会得到相同的错误。如果不幸运地将它添加到pom.xml,我仍然会得到相同的错误。