Spring Boot 2.0 新人会踩的坑--启动报404错误
转载自:http://www.javaman.cn/channels/sb2
启动程序,验证效果

根据图示,点击按钮,来启动 Spring Boot Web 程序, 查看控制台输出:
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.1.4.RELEASE)
2019-04-14 19:57:59.795 INFO 3680 --- [ main] com.example.demo.DemoApplication : Starting DemoApplication on 192.168.0.100 with PID 3680 (/Users/a123123/Work/IdeaProjects/demo/target/classes started by allen-jiang in /Users/a123123/Work/IdeaProjects/demo)
2019-04-14 19:57:59.798 INFO 3680 --- [ main] com.example.demo.DemoApplication : No active profile set, falling back to default profiles: default
2019-04-14 19:58:00.666 INFO 3680 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2019-04-14 19:58:00.689 INFO 3680 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2019-04-14 19:58:00.689 INFO 3680 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.17]
2019-04-14 19:58:00.756 INFO 3680 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2019-04-14 19:58:00.757 INFO 3680 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 920 ms
2019-04-14 19:58:00.978 INFO 3680 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2019-04-14 19:58:01.183 INFO 3680 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2019-04-14 19:58:01.186 INFO 3680 --- [ main] com.example.demo.DemoApplication : Started DemoApplication in 1.678 seconds (JVM running for 2.176)
当控制台日志中输出了 Tomcat started on port(s): 8888 (http) with context path ''时,表示内嵌的 Tomcat 容器已经启动成功了,端口为 8080 !
接下来,我们在浏览器上访问 http://localhost:8888/hello 接口,验证一下,接口是否能够正常访问:

返回了我们想要的 Hello, Spring Boot ! 字符串,接口访问正常,大工告成!
SpringbootApplication.png
注意!!!: @SpringBootApplication注解的类必须要放在包扫描的最外层才可以。


否则页面会报404错误。
四、总结
本文中,我们首先了解了什么是 Spring Boot, 以及Spring Boot 的相关特性,最后我们手把手学习了如何搭建一个 Spring Boot 项目,并编写了第一个接口且访问成功。
通过实际操作,真切地感受到了 Spring Boot 的魅力所在!老铁,双击 666!
Spring Boot 2.0 新人会踩的坑--启动报404错误的更多相关文章
- 【spring boot】spring boot 2.0 项目中使用mysql驱动启动创建的mysql数据表,引擎是MyISAM,如何修改启动时创建数据表引擎为【spring boot 2.0】
默认创建数据表使用的引擎是MyISAM 2018-05-14 14:16:37.283 INFO 7328 --- [ restartedMain] org.hibernate.dialect.Dia ...
- Spring Boot 2.0正式发布,新特性解读
作者|翟永超 Spring Boot 2.0 来啦,有哪些新特性?升级吗? 写在前面 北京时间 3 月 1 日,经过漫长的等待之后,Spring Boot 2.0 正式发布.作为 Spring 生态中 ...
- Spring Boot 2.0 版的开源项目云收藏来了!
给大家聊一聊云收藏从 Spring Boot 1.0 升级到 2.0 所踩的坑 先给大家晒一下云收藏的几个数据,作为一个 Spring Boot 的开源项目(https://github.com/cl ...
- springboot2.0(一):【重磅】Spring Boot 2.0权威发布
就在昨天Spring Boot2.0.0.RELEASE正式发布,今天早上在发布Spring Boot2.0的时候还出现一个小插曲,将Spring Boot2.0同步到Maven仓库的时候出现了错误, ...
- 业余草分享 Spring Boot 2.0 正式发布的新特性
就在昨天Spring Boot2.0.0.RELEASE正式发布,今天早上在发布Spring Boot2.0的时候还出现一个小插曲,将Spring Boot2.0同步到Maven仓库的时候出现了错误, ...
- Spring Boot 2.0(二):Spring Boot 2.0尝鲜-动态 Banner
Spring Boot 2.0 提供了很多新特性,其中就有一个小彩蛋:动态 Banner,今天我们就先拿这个来尝尝鲜. 配置依赖 使用 Spring Boot 2.0 首先需要将项目依赖包替换为刚刚发 ...
- Spring Boot 2.0(四):使用 Docker 部署 Spring Boot
Docker 技术发展为微服务落地提供了更加便利的环境,使用 Docker 部署 Spring Boot 其实非常简单,这篇文章我们就来简单学习下. 首先构建一个简单的 Spring Boot 项目, ...
- spring boot 2.0.0由于版本不匹配导致的NoSuchMethodError问题解析
spring boot升级到2.0.0以后,项目突然报出 NoSuchMethodError: org.springframework.boot.builder.SpringApplicationBu ...
- Spring Boot 2.0(六):使用 Docker 部署 Spring Boot 开源软件云收藏
云收藏项目已经开源2年多了,作为当初刚开始学习 Spring Boot 的练手项目,使用了很多当时很新的技术,现在看来其实很多新技术是没有必要使用的,但做为学习案例来讲确实是一个绝佳的 Spring ...
- Spring Boot 2.0系列文章(五):Spring Boot 2.0 项目源码结构预览
关注我 转载请务必注明原创地址为:http://www.54tianzhisheng.cn/2018/04/15/springboot2_code/ 项目结构 结构分析: Spring-boot-pr ...
随机推荐
- 使用XAG配置GoldenGate在RAC集群环境中的高可用
背景:本文是根据实际客户测试需求整理,因为客户OGG所在环境只有GI集群,数据库部署在其他位置,所以会有一些差异,但核心思路一致,已完全测试通过,整理出来供大家参考. 1.前期准备 2.创建ACFS文 ...
- 图像列表组件(TImageList)
TImageList 组件是一组同样尺寸的图像列表,每一个图像由它的Index值查询. 1.TImageList组件的典型用法 图形列表用于建立和管理大量的图像,主要是配合菜单或者工具栏按钮的使用.图 ...
- 《ASP.NET Core 微服务实战》-- 读书笔记(第3章)
第 3 章 使用 ASP.NET Core 开发微服务 微服务定义 微服务是一个支持特定业务场景的独立部署单元.它借助语义化版本管理.定义良好的 API 与其他后端服务交互.它的天然特点就是严格遵守单 ...
- ArrayList中的遍历删除
ArrayList 中的遍历删除 在代码编写过程中经常会遇到这样的要求:遍历一个线性表,要求只遍历一遍(时间复杂度\(O(n)\)),删除符合指定条件的元素,且要求空间复杂度 \(O(1)\). 例如 ...
- 移位寄存器的设计(VHDL)及testbench的编写
移位寄存器是一种常用的存储元件,此处由D触发器构成,如下图所示. 当时钟边沿到来时,存储在移位寄存器的数据朝一个方向移动一个BIT位. 移位寄存器的功能主要为:串并转换,并串转换和同步延迟. vhdl ...
- NC19857 最后的晚餐(dinner)
题目链接 题目 题目描述 **YZ(已被和谐)的食堂实在是太挤辣!所以Apojacsleam现在想邀请他的一些好友去校外吃一顿饭,并在某酒店包下了一桌饭. 当Apojacsleam和他的同学们 ...
- Python 中获取文件名
Python 获取文件名import osimport sys # ①获取当前文件名os.path.basename(__file__)# ②获取程序启动文件名os.path.basename(sys ...
- The Network Adapter could not establish the connection errorCode 17002, state 08006
问题说明 今天在centos7虚拟机中运行java程序,程序启动需要连接主机的oracle,报错: The Network Adapter could not establish the connec ...
- centos7下修改mysql5.5字符集
1.查看现有数据库编码 show variables like "%char%"; 2.修改mysql配置文件:/etc/my.cnf(以实际安装环境为准) 在[client]字段 ...
- centos7.5 hadoop NAT 静态IP网络环境搭建
1 设置 VMware 网络环境 1. 选择VMNet8 并将子网IP 修改为 192.168.10.0,保证集群ip都在这个网段下 2. 选择NAT 设置,配置NAT的网关为 192.168.10. ...