springboot demo错误整理

springboot官方文档:https://docs.spring.io/spring-boot/docs/2.1.2.RELEASE/reference/htmlsingle/#getting-started-first-application
最近看接口自动化,会用到spring-boot。于是开始从第一个简单的demo开始:
找到官方文档,直接从11结处开始做。
在这里插入图片描述
主要记录一下遇到的错误与解决方法:
1.
spring boot 启动报错:错误: 找不到或无法加载主类 com.xxxx.xxxx.Example
在这里插入图片描述
方案一:maven build失败
项目-》右键-》Run As -》Maven build…
原地址:https://blog.csdn.net/baofengyu90/article/details/82859413
方案二:右键项目-build path:检查下面三个设置,是否为同一个jdk版本。我都用的1.8。设置完成后,这个问题解决了
在这里插入图片描述
2.继续执行,不报这个错了。又出现下一个错误
Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.x.x:compile

Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile

原因:pom文件没有配置jdk编译
解决方法:
在pom.xml中配置jdk版本:

 <!-- java编译插件 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>

该问题原博客解决地址:https://blog.csdn.net/weixin_42167717/article/details/80377123
3.接着运行,又报错了。。很崩溃
The type org.springframework.context.ConfigurableApplicationContext cannot be resolved.
在这里插入图片描述
解决方法:
a 在命令行中转到项目目录。 确保您的POM.xml与您的命令行在同一个目录中
b 运行命令 mvn dependency:purge-local-repository
c 如果您收到构建成功的消息,表示错误已解决。
最后构建成功了!
该问题原博客解决地址:https://blog.csdn.net/svneclipse/article/details/80719480
3.
最后终于运行成功!!一个简单的demo,还什么都没做呢!遇到这些问题,终于解决了!实属不易
在这里插入图片描述

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值