springboot demo错误整理

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/sinat_34817187/article/details/86572654

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,还什么都没做呢!遇到这些问题,终于解决了!实属不易
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/sinat_34817187/article/details/86572654
今日推荐