自学SpringBoot中遇到的问题及解决方案,只为自己以后Review!
解决方案:
1、检查了url拼写是否有误,是否为RequestMapping中的value排除这一问题后
2、其次看application.properties配置文件中是否配置误,确认端口号、基地址等信息没有问题后
3、定位到最后一个问题就是主方法springbootApplication位置没有放到调用方法的最外层,导致服务启动时没有扫描到当前所访问的路径解决办法:将springbootApplication类放在所有controller的最外层包下,使所有想要访问的controller在其下的子包中,也就是说,若springbootApplication放在com.zxm包下,则想要在服务启动后调用的controller就要放在com.zxm.XXX下即可解决接口调用不了的问题
2、Failed to resolve org.junit.platform:junit-platform-launcher:1.7.0
解决方案:配置pom.xml添加:
<dependency> <groupId>org.junit.platform</groupId> <artifactId>junit-platform-launcher</artifactId> <version>1.7.0</version> <scope>test</scope> </dependency>
3、如何使用maven打包
>mvn clean package
4、Spring Boot 打包报错Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0
解决办法:pom.xml配置文件中添加3.1.0配置
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId> <version>3.1.0</version> </plugin>
5、You must configure either the server or JDBC driver (via the serverTimezone conf)
解决办法:配置后面加 ?serverTimezone=UTC
