码迷,mamicode.com
首页 > 编程语言 > 详细

SpringBoot项目启动错误,解决方式

时间:2020-04-18 18:24:16      阅读:135      评论:0      收藏:0      [点我收藏+]

标签:load   service   control   ase   exce   tar   exception   sof   noclass   

SpringBoot项目启动错误,错误信息如下

Connected to the target VM, address: ‘127.0.0.1:53101‘, transport: ‘socket‘
Exception in thread "main" java.lang.NoClassDefFoundError: org/springframework/util/unit/DataSize
at org.springframework.boot.convert.StringToDataSizeConverter.getConvertibleTypes(StringToDataSizeConverter.java:40)
at org.springframework.core.convert.support.GenericConversionService$Converters.add(GenericConversionService.java:507)
at org.springframework.core.convert.support.GenericConversionService.addConverter(GenericConversionService.java:105)
at org.springframework.boot.convert.ApplicationConversionService.addApplicationConverters(ApplicationConversionService.java:116)
at org.springframework.boot.convert.ApplicationConversionService.configure(ApplicationConversionService.java:100)
at org.springframework.boot.convert.ApplicationConversionService.<init>(ApplicationConversionService.java:61)
at org.springframework.boot.convert.ApplicationConversionService.<init>(ApplicationConversionService.java:54)
at org.springframework.boot.convert.ApplicationConversionService.getSharedInstance(ApplicationConversionService.java:80)
at org.springframework.boot.SpringApplication.configureEnvironment(SpringApplication.java:478)
at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:343)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:308)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215)
at com.course.application.Application.main(Application.java:11)
Caused by: java.lang.ClassNotFoundException: org.springframework.util.unit.DataSize
at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 14 more
Disconnected from the target VM, address: ‘127.0.0.1:53101‘, transport: ‘socket‘

Process finished with exit code 1

解决方式:
是因为指定父类的版本号 和 下面的depenency 版本不同。

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.2.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>

 

但是我其他的Springboot 的依赖,我又给他指定了其他的版本, <version>2.2.5.RELEASE</version>,如下。

<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot</artifactId>
<version>2.2.5.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-web -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>2.2.5.RELEASE</version>
</dependency>

  

这样是错误的,导致两个版本不一致。

此时可以不指定版本,因为parent已经指定了版本,直接继承父类的版本即可

<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-web -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

  

再重新启动项目,就会发现启动成功啦。

SpringBoot项目启动错误,解决方式

标签:load   service   control   ase   exce   tar   exception   sof   noclass   

原文地址:https://www.cnblogs.com/eathertan/p/12727197.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!