gpt4 book ai didi

java - 如何解决java.lang.NoClassDefFoundError : com/google/api/client/repackaged/com/google/common/base/Strings

转载 作者:行者123 更新时间:2023-12-02 09:30:04 27 4
gpt4 key购买 nike

我在 StackOverflow 上搜索了类似的问题,但没有找到任何内容。

我的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.stackoverflow.example</groupId>
<artifactId>dmytro-camel-demo</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>jar</packaging>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.4.RELEASE</version>
</parent>

<properties>
<jdk.version>1.8</jdk.version>
<kotlin.version>1.3.31</kotlin.version>
<camel.version>2.23.1</camel.version>
<spring-boot.version>2.1.4.RELEASE</spring-boot.version>
<google-cloud.version>1.92.0</google-cloud.version>
<google-firestore.version>1.22.0</google-firestore.version>

<javax-jaxb.version>2.2.11</javax-jaxb.version>
<javax-activation.version>1.1.1</javax-activation.version>
</properties>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<!-- Kotlin -->
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-jdk8</artifactId>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-reflect</artifactId>
</dependency>

<!-- Camel -->
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-spring-boot-starter</artifactId>
<version>${camel.version}</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-google-pubsub-starter</artifactId>
<version>${camel.version}</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-zipfile</artifactId>
<version>${camel.version}</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-http</artifactId>
<version>${camel.version}</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-jetty</artifactId>
<version>${camel.version}</version>
</dependency>

<!-- GCP -->
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-storage</artifactId>
<version>${google-cloud.version}</version>
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-firestore</artifactId>
<version>${google-firestore.version}</version>
</dependency>

<!-- JDK >=10 doesn't bundle JAXB -->
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>${javax-jaxb.version}</version>
</dependency>
<dependency>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
<version>${javax-activation.version}</version>
</dependency>

<!-- Test -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot.version}</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<version>${kotlin.version}</version>

<configuration>
<args>
<arg>-java-parameters</arg>
</args>
<compilerPlugins>
<!-- Spring compiler plugin will automatically open relevant classes and members for Spring AOP support. See https://kotlinlang.org/docs/reference/compiler-plugins.html -->
<plugin>spring</plugin>
</compilerPlugins>
<jvmTarget>${jdk.version}</jvmTarget>
</configuration>

<executions>
<execution>
<id>compile</id>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<sourceDirs>
<sourceDir>${project.basedir}/src/main/kotlin</sourceDir>
</sourceDirs>
</configuration>
</execution>
<execution>
<id>test-compile</id>
<goals>
<goal>test-compile</goal>
</goals>
<configuration>
<sourceDirs>
<sourceDir>${project.basedir}/src/test/kotlin</sourceDir>
</sourceDirs>
</configuration>
</execution>
</executions>

<!-- Needed by the Spring compiler plugin. -->
<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-allopen</artifactId>
<version>${kotlin.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>ci</id>

<properties>
<revision>0.0.1-SNAPSHOT</revision>
</properties>
</profile>
</profiles>
</project>

我收到以下错误:

java.lang.NoClassDefFoundError: com/google/api/client/repackaged/com/google/common/base/Strings at org.apache.camel.component.google.pubsub.GooglePubsubEndpoint.afterPropertiesSet(GooglePubsubEndpoint.java:87) ~[camel-google-pubsub-2.23.1.jar:2.23.1] at org.apache.camel.component.google.pubsub.GooglePubsubEndpoint.createConsumer(GooglePubsubEndpoint.java:109) ~[camel-google-pubsub-2.23.1.jar:2.23.1] at org.apache.camel.impl.EventDrivenConsumerRoute.addServices(EventDrivenConsumerRoute.java:69) ~[camel-core-2.23.1.jar:2.23.1] at org.apache.camel.impl.DefaultRoute.onStartingServices(DefaultRoute.java:107) ~[camel-core-2.23.1.jar:2.23.1] at org.apache.camel.impl.RouteService.doWarmUp(RouteService.java:172) ~[camel-core-2.23.1.jar:2.23.1] at org.apache.camel.impl.RouteService.warmUp(RouteService.java:145) ~[camel-core-2.23.1.jar:2.23.1] at org.apache.camel.impl.DefaultCamelContext.doWarmUpRoutes(DefaultCamelContext.java:3953) ~[camel-core-2.23.1.jar:2.23.1] at org.apache.camel.impl.DefaultCamelContext.safelyStartRouteServices(DefaultCamelContext.java:3860) ~[camel-core-2.23.1.jar:2.23.1] at org.apache.camel.impl.DefaultCamelContext.doStartOrResumeRoutes(DefaultCamelContext.java:3646) ~[camel-core-2.23.1.jar:2.23.1] at org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:3489) ~[camel-core-2.23.1.jar:2.23.1] at org.apache.camel.impl.DefaultCamelContext$4.call(DefaultCamelContext.java:3248) ~[camel-core-2.23.1.jar:2.23.1] at org.apache.camel.impl.DefaultCamelContext$4.call(DefaultCamelContext.java:3244) ~[camel-core-2.23.1.jar:2.23.1] at org.apache.camel.impl.DefaultCamelContext.doWithDefinedClassLoader(DefaultCamelContext.java:3267) ~[camel-core-2.23.1.jar:2.23.1] at org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:3244) ~[camel-core-2.23.1.jar:2.23.1] at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:72) ~[camel-core-2.23.1.jar:2.23.1] at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:3160) ~[camel-core-2.23.1.jar:2.23.1] at org.apache.camel.spring.SpringCamelContext.start(SpringCamelContext.java:133) ~[camel-spring-2.23.1.jar:2.23.1] at org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:174) ~[camel-spring-2.23.1.jar:2.23.1] at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172) ~[spring-context-5.1.6.RELEASE.jar:5.1.6.RELEASE] at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165) ~[spring-context-5.1.6.RELEASE.jar:5.1.6.RELEASE] at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) ~[spring-context-5.1.6.RELEASE.jar:5.1.6.RELEASE] at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:402) ~[spring-context-5.1.6.RELEASE.jar:5.1.6.RELEASE] at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:359) ~[spring-context-5.1.6.RELEASE.jar:5.1.6.RELEASE] at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:896) ~[spring-context-5.1.6.RELEASE.jar:5.1.6.RELEASE] at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.finishRefresh(ServletWebServerApplicationContext.java:163) ~[spring-boot-2.1.4.RELEASE.jar:2.1.4.RELEASE] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:552) ~[spring-context-5.1.6.RELEASE.jar:5.1.6.RELEASE] at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:142) ~[spring-boot-2.1.4.RELEASE.jar:2.1.4.RELEASE] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:775) [spring-boot-2.1.4.RELEASE.jar:2.1.4.RELEASE] at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) [spring-boot-2.1.4.RELEASE.jar:2.1.4.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:316) [spring-boot-2.1.4.RELEASE.jar:2.1.4.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260) [spring-boot-2.1.4.RELEASE.jar:2.1.4.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248) [spring-boot-2.1.4.RELEASE.jar:2.1.4.RELEASE] at com.stackoverflow.example.ExampleAppKt.main(ExampleApp.kt:13) [classes/:na] Caused by: java.lang.ClassNotFoundException: com.google.api.client.repackaged.com.google.common.base.Strings at java.net.URLClassLoader.findClass(URLClassLoader.java:382) ~[na:1.8.0_202-release] at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_202-release] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349) ~[na:1.8.0_202-release] at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_202-release] ... 33 common frames omitted

如何解决?我做错了什么吗?

最佳答案

我已经编写了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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.8.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>demo</name>
<description>Demo project for Spring Boot</description>

<properties>
<java.version>1.8</java.version>
</properties>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>


<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-jdk8</artifactId>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-reflect</artifactId>
</dependency>

<!-- Camel -->

<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-spring-boot-starter</artifactId>
</dependency>


<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-google-pubsub-starter</artifactId>
</dependency>

<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-zipfile</artifactId>
</dependency>

<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-http</artifactId>
<version>2.23.1</version>
</dependency>


<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-jetty</artifactId>
<version>2.23.1</version>
</dependency>

<!-- GCP -->
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-storage</artifactId>
<version>1.86.0</version>
</dependency>


<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-firestore</artifactId>
<version>1.17.0</version>
</dependency>


<dependency>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
</dependency>

<!-- Test -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>

项目运行良好。你能检查一下吗?

关于java - 如何解决java.lang.NoClassDefFoundError : com/google/api/client/repackaged/com/google/common/base/Strings,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58059797/

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