gpt4 book ai didi

spring - 包含 Spring 芯,为什么会出现 "java.lang.ClassNotFoundException: org.springframework.core.ErrorCoded"错误?

转载 作者:行者123 更新时间:2023-12-03 03:57:01 51 4
gpt4 key购买 nike

我正在使用 Java 8 和 Spring 5。我正在尝试构建的这个 Spring 引导应用程序具有以下等级依赖项......

repositories {
mavenCentral()
}

sourceCompatibility = 1.8
targetCompatibility = 1.8

dependencies {
compile 'org.springframework.boot:spring-boot-starter-data-mongodb:2.1.5.RELEASE'
compile 'org.springframework:spring-web:5.1.7.RELEASE'
compile 'org.springframework:spring-core:5.1.7.RELEASE'
}

构建应用程序并运行后,我收到以下错误(“java.lang.ClassNotFoundException: org.springframework.core.ErrorCoded”)。我包括 Spring 芯,所以我不确定它在提示什么......
localhost:todoapp-backend davea$ java -jar ./build/libs/spring-data-mongodb-example-1.0.jar
12:37:24.249 [main] DEBUG org.springframework.boot.logging.ClasspathLoggingApplicationListener - Application failed to start with classpath: [jar:file:/Users/davea/Documents/workspace/todoapp-backend/build/libs/spring-data-mongodb-example-1.0.jar!/BOOT-INF/classes!/, jar:file:/Users/davea/Documents/workspace/todoapp-backend/build/libs/spring-data-mongodb-example-1.0.jar!/BOOT-INF/lib/spring-boot-starter-data-mongodb-2.1.5.RELEASE.jar!/, jar:file:/Users/davea/Documents/workspace/todoapp-backend/build/libs/spring-data-mongodb-example-1.0.jar!/BOOT-INF/lib/spring-web-5.1.7.RELEASE.jar!/, jar:file:/Users/davea/Documents/workspace/todoapp-backend/build/libs/spring-data-mongodb-example-1.0.jar!/BOOT-INF/lib/spring-core-5.1.7.RELEASE.jar!/, jar:file:/Users/davea/Documents/workspace/todoapp-backend/build/libs/spring-data-mongodb-example-1.0.jar!/BOOT-INF/lib/spring-boot-starter-1.5.1.RELEASE.jar!/, jar:file:/Users/davea/Documents/workspace/todoapp-backend/build/libs/spring-data-mongodb-example-1.0.jar!/BOOT-INF/lib/mongodb-driver-3.4.1.jar!/, jar:file:/Users/davea/Documents/workspace/todoapp-backend/build/libs/spring-data-mongodb-example-1.0.jar!/BOOT-INF/lib/spring-data-mongodb-1.10.0.RELEASE.jar!/, jar:file:/Users/davea/Documents/workspace/todoapp-backend/build/libs/spring-data-mongodb-example-1.0.jar!/BOOT-INF/lib/spring-beans-4.3.6.RELEASE.jar!/, jar:file:/Users/davea/Documents/workspace/todoapp-backend/build/libs/spring-data-mongodb-example-1.0.jar!/BOOT-INF/lib/spring-jcl-5.1.7.RELEASE.jar!/, jar:file:/Users/davea/Documents/workspace/todoapp-backend/build/libs/spring-data-mongodb-example-1.0.jar!/BOOT-INF/lib/spring-boot-1.5.1.RELEASE.jar!/, jar:file:/Users/davea/Documents/workspace/todoapp-backend/build/libs/spring-data-mongodb-example-1.0.jar!/BOOT-INF/lib/spring-boot-autoconfigure-1.5.1.RELEASE.jar!/, jar:file:/Users/davea/Documents/workspace/todoapp-backend/build/libs/spring-data-mongodb-example-1.0.jar!/BOOT-INF/lib/spring-boot-starter-logging-1.5.1.RELEASE.jar!/, jar:file:/Users/davea/Documents/workspace/todoapp-backend/build/libs/spring-data-mongodb-example-1.0.jar!/BOOT-INF/lib/snakeyaml-1.17.jar!/, jar:file:/Users/davea/Documents/workspace/todoapp-backend/build/libs/spring-data-mongodb-example-1.0.jar!/BOOT-INF/lib/mongodb-driver-core-3.4.1.jar!/, jar:file:/Users/davea/Documents/workspace/todoapp-backend/build/libs/spring-data-mongodb-example-1.0.jar!/BOOT-INF/lib/bson-3.4.1.jar!/, jar:file:/Users/davea/Documents/workspace/todoapp-backend/build/libs/spring-data-mongodb-example-1.0.jar!/BOOT-INF/lib/spring-tx-4.3.6.RELEASE.jar!/, jar:file:/Users/davea/Documents/workspace/todoapp-backend/build/libs/spring-data-mongodb-example-1.0.jar!/BOOT-INF/lib/spring-context-4.3.6.RELEASE.jar!/, jar:file:/Users/davea/Documents/workspace/todoapp-backend/build/libs/spring-data-mongodb-example-1.0.jar!/BOOT-INF/lib/spring-expression-4.3.6.RELEASE.jar!/, jar:file:/Users/davea/Documents/workspace/todoapp-backend/build/libs/spring-data-mongodb-example-1.0.jar!/BOOT-INF/lib/spring-data-commons-1.13.0.RELEASE.jar!/, jar:file:/Users/davea/Documents/workspace/todoapp-backend/build/libs/spring-data-mongodb-example-1.0.jar!/BOOT-INF/lib/slf4j-api-1.7.22.jar!/, jar:file:/Users/davea/Documents/workspace/todoapp-backend/build/libs/spring-data-mongodb-example-1.0.jar!/BOOT-INF/lib/logback-classic-1.1.9.jar!/, jar:file:/Users/davea/Documents/workspace/todoapp-backend/build/libs/spring-data-mongodb-example-1.0.jar!/BOOT-INF/lib/jcl-over-slf4j-1.7.22.jar!/, jar:file:/Users/davea/Documents/workspace/todoapp-backend/build/libs/spring-data-mongodb-example-1.0.jar!/BOOT-INF/lib/jul-to-slf4j-1.7.22.jar!/, jar:file:/Users/davea/Documents/workspace/todoapp-backend/build/libs/spring-data-mongodb-example-1.0.jar!/BOOT-INF/lib/log4j-over-slf4j-1.7.22.jar!/, jar:file:/Users/davea/Documents/workspace/todoapp-backend/build/libs/spring-data-mongodb-example-1.0.jar!/BOOT-INF/lib/spring-aop-4.3.6.RELEASE.jar!/, jar:file:/Users/davea/Documents/workspace/todoapp-backend/build/libs/spring-data-mongodb-example-1.0.jar!/BOOT-INF/lib/logback-core-1.1.9.jar!/]
12:37:24.255 [main] ERROR org.springframework.boot.SpringApplication - Application startup failed
java.lang.NoClassDefFoundError: org/springframework/core/ErrorCoded
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:94)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:94)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:94)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.springframework.boot.bind.RelaxedDataBinder.modifyProperties(RelaxedDataBinder.java:146)
at org.springframework.boot.bind.RelaxedDataBinder.doBind(RelaxedDataBinder.java:128)
at org.springframework.validation.DataBinder.bind(DataBinder.java:740)
at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.bindSpringProfiles(ConfigFileApplicationListener.java:530)
at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.bindSpringProfiles(ConfigFileApplicationListener.java:523)
at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.handleProfileProperties(ConfigFileApplicationListener.java:515)
at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.loadIntoGroup(ConfigFileApplicationListener.java:476)
at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.load(ConfigFileApplicationListener.java:459)
at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.load(ConfigFileApplicationListener.java:380)
at org.springframework.boot.context.config.ConfigFileApplicationListener.addPropertySources(ConfigFileApplicationListener.java:215)
at org.springframework.boot.context.config.ConfigFileApplicationListener.postProcessEnvironment(ConfigFileApplicationListener.java:184)
at org.springframework.boot.context.config.ConfigFileApplicationListener.onApplicationEnvironmentPreparedEvent(ConfigFileApplicationListener.java:171)
at org.springframework.boot.context.config.ConfigFileApplicationListener.onApplicationEvent(ConfigFileApplicationListener.java:157)
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:167)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:122)
at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:73)
at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:54)
at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:336)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:307)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1162)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1151)
at com.mkyong.Application.main(Application.java:20)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:50)
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51)
Caused by: java.lang.ClassNotFoundException: org.springframework.core.ErrorCoded
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:94)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)

最佳答案

请不要在您的 gradle 构建文件中将 Spring 依赖项与 Spring Boot 依赖项混合。对于您的项目,依赖项应如下所示:

dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-mongodb:2.1.5.RELEASE'
implementation 'org.springframework.boot:spring-boot-starter-web:2.1.5.RELEASE'
}

我建议使用 https://start.spring.io/为了生成一个包含你想要的所有依赖项的新 Spring Boot 项目。

关于spring - 包含 Spring 芯,为什么会出现 "java.lang.ClassNotFoundException: org.springframework.core.ErrorCoded"错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56210415/

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