后来去maven仓库搜了一下没有2.1.5版本的spring-boot-starter-parent的包。
报错的原因是jar包版本太高了 改成2.1.1解决
org.springframework.boot
spring-boot-starter-parent
2.1.1.RELEASE
关于启动服务后无法访问地址,信息如下:
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Sat Jun 29 11:00:06 CST 2019
There was an unexpected error (type=Not Found, status=404).
No message available
解决办法:
1、引入thymeleaf引擎
查看是否忘记引入了thymeleaf依赖,没有引入则在mawen的pom.xml文件引入,pom.xml文件的thymeleaf引入如下
org.springframework.boot
spring-boot-starter-thymeleaf
2、检查访问地址是否正确
检查访问地址是否写正确,地址应该为controller的路径加上RequestMapping的路径。
如下代码的访问地址为:http://localhost:8080/getUList
@Controllerpublic classUlevelController {
@RequestMapping(value="getUList", method=RequestMethod.GET)publicString getUlevelList() {
………………return "ulevel/ulevelList";
}
}
@Controller
@RequestMapping(value="/hhllow")public classUlevelController {
@RequestMapping(value="getUList", method=RequestMethod.GET)publicString getUlevelList() {
………………return "ulevel/ulevelList";
}
}
这里顺便说明,如果访问的是hello.html,但是hello.html不存在,不是抛出404的错误,而是500的错误,如下信息:
Error resolving template "/hello", template might not exist or might not be accessible by
any of the configured Template Resolvers
3、包路径写对
application.java文件的包必须是项目下的父路径,其他类的包路径必须是其子路径(同一级目录也可启动服务),如: