我无法启动Spring Boot应用程序。
下面是堆栈跟踪和pom文件的内容:
org.springframework.boot.autoconfigure.context.ConfigurationPropertiesAutoConfiguration
----------
org.springframework.boot.SpringApplication.refresh(SpringApplication.java:746) [spring-boot-2.4.0-SNAPSHOT.jar:2.4.0-SNAPSHOT]at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:406) [spring-boot-2.4.0-SNAPSHOT.jar:2.4.0-SNAPSHOT]at org.springframework.boot.SpringApplication.run(SpringApplication.java:322) [spring-boot-2.4.0-SNAPSHOT.jar:2.4.0-SNAPSHOT]at org.springframework.boot.SpringApplication.run(SpringApplication.java:1259) [spring-boot-2.4.0-SNAPSHOT.jar:2.4.0-SNAPSHOT]at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248) [spring-boot-2.4.0-SNAPSHOT.jar:2.4.0-SNAPSHOT]
at com.techm.jobs.user.JobZillaApplication.main(JobZillaApplication.java:13) [classes/:na]
Caused by: java.lang.IllegalStateException: Failed to introspect Class [springfox.documentation.spring.web.ObjectMapperConfigurer] from ClassLoader [sun.misc.Launcher$AppClassLoader@659e0bfd]
at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:481) ~[spring-core-5.3.0-SNAPSHOT.jar:5.3.0-SNAPSHOT]
at org.springframework.util.ReflectionUtils.doWithLocalMethods(ReflectionUtils.java:321) ~[spring-core-5.3.0-SNAPSHOT.jar:5.3.0-SNAPSHOT]
at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.buildPersistenceMetadata(PersistenceAnnotationBeanPostProcessor.java:418) ~[spring-orm-5.3.0-SNAPSHOT.jar:5.3.0-SNAPSHOT]
at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.findPersistenceMetadata(PersistenceAnnotationBeanPostProcessor.java:389) ~[spring-orm-5.3.0-SNAPSHOT.jar:5.3.0-SNAPSHOT]
at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.postProcessMergedBeanDefinition(PersistenceAnnotationBeanPostProcessor.java:336) ~[spring-orm-5.3.0-SNAPSHOT.jar:5.3.0-SNAPSHOT]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyMergedBeanDefinitionPostProcessors(AbstractAutowireCapableBeanFactory.java:1100) ~[spring-beans-5.3.0-SNAPSHOT.jar:5.3.0-SNAPSHOT]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:583) ~[spring-beans-5.3.0-SNAPSHOT.jar:5.3.0-SNAPSHOT]
... 16 common frames omitted
Caused by: java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/ObjectMapper
at java.lang.Class.getDeclaredMethods0(Native Method) ~[na:1.8.0_60]
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701) ~[na:1.8.0_60]
at java.lang.Class.getDeclaredMethods(Class.java:1975) ~[na:1.8.0_60]
at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:463) ~[spring-core-5.3.0-SNAPSHOT.jar:5.3.0-SNAPSHOT]
... 22 common frames omitted
Caused by: java.lang.ClassNotFoundException: com.fasterxml.jackson.databind.ObjectMapper
at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[na:1.8.0_60]
at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_60]
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) ~[na:1.8.0_60]
at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_60]
... 26 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.4.0-SNAPSHOT</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.techm.jobs.user</groupId>
<artifactId>JobZilla</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>JobZilla</name>
<description>JobZilla 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>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.7.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.7.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
</dependency>
<dependency>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy</artifactId>
<version>1.8.16</version>
</dependency>
<dependency>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy-agent</artifactId>
<version>1.8.16</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
</repository>
<repository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
</pluginRepository>
<pluginRepository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</project>
答案 0 :(得分:0)
库springfox-swagger2希望您自己提供jackson-databind依赖性,请参见https://github.com/springfox/springfox/blob/2.7.0/gradle/dependencies.gradle第60-61行。
只需向jackson-databind添加依赖项:
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.8.7</version>
</dependency>
2.8.7也来自springfox-swagger2依赖项。gradle。