转载自: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错误的更多相关文章

  1. 【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 ...

  2. Spring Boot 2.0正式发布,新特性解读

    作者|翟永超 Spring Boot 2.0 来啦,有哪些新特性?升级吗? 写在前面 北京时间 3 月 1 日,经过漫长的等待之后,Spring Boot 2.0 正式发布.作为 Spring 生态中 ...

  3. Spring Boot 2.0 版的开源项目云收藏来了!

    给大家聊一聊云收藏从 Spring Boot 1.0 升级到 2.0 所踩的坑 先给大家晒一下云收藏的几个数据,作为一个 Spring Boot 的开源项目(https://github.com/cl ...

  4. springboot2.0(一):【重磅】Spring Boot 2.0权威发布

    就在昨天Spring Boot2.0.0.RELEASE正式发布,今天早上在发布Spring Boot2.0的时候还出现一个小插曲,将Spring Boot2.0同步到Maven仓库的时候出现了错误, ...

  5. 业余草分享 Spring Boot 2.0 正式发布的新特性

    就在昨天Spring Boot2.0.0.RELEASE正式发布,今天早上在发布Spring Boot2.0的时候还出现一个小插曲,将Spring Boot2.0同步到Maven仓库的时候出现了错误, ...

  6. Spring Boot 2.0(二):Spring Boot 2.0尝鲜-动态 Banner

    Spring Boot 2.0 提供了很多新特性,其中就有一个小彩蛋:动态 Banner,今天我们就先拿这个来尝尝鲜. 配置依赖 使用 Spring Boot 2.0 首先需要将项目依赖包替换为刚刚发 ...

  7. Spring Boot 2.0(四):使用 Docker 部署 Spring Boot

    Docker 技术发展为微服务落地提供了更加便利的环境,使用 Docker 部署 Spring Boot 其实非常简单,这篇文章我们就来简单学习下. 首先构建一个简单的 Spring Boot 项目, ...

  8. spring boot 2.0.0由于版本不匹配导致的NoSuchMethodError问题解析

    spring boot升级到2.0.0以后,项目突然报出 NoSuchMethodError: org.springframework.boot.builder.SpringApplicationBu ...

  9. Spring Boot 2.0(六):使用 Docker 部署 Spring Boot 开源软件云收藏

    云收藏项目已经开源2年多了,作为当初刚开始学习 Spring Boot 的练手项目,使用了很多当时很新的技术,现在看来其实很多新技术是没有必要使用的,但做为学习案例来讲确实是一个绝佳的 Spring ...

  10. Spring Boot 2.0系列文章(五):Spring Boot 2.0 项目源码结构预览

    关注我 转载请务必注明原创地址为:http://www.54tianzhisheng.cn/2018/04/15/springboot2_code/ 项目结构 结构分析: Spring-boot-pr ...

随机推荐

  1. 绝对凶器!NVIDIA Titan Z细节全曝光

    AMD Radeon R9 295X2已经拉开了新一代双芯卡皇大战的序幕,接下来就等NVIDIA GeForce GTX Titan Z的登场了.最新消息显示,它比原计划推迟了一个星期,将在5月8日正 ...

  2. 3.4 CSP-J 补赛游寄

    3.4 CSP-J 补赛游寄 Day -? 听说要去打比赛. Day -7 今天家长会,老师公布成绩 /fn/fn/fn.政治考废了,然后其他都挺好. 语文 $ 95 $,数学 $ 118 $,英语 ...

  3. 洛谷P2670 扫雷游戏 关于区域搜索标记的坐标增量法

    最简单的思路就是扫描一边所有节点,对每个非地雷节点,去检查一下他八个方向的元素是否有'*',有的话就加一 但是逐个写出有点麻烦,我们不妨定义两个增量数组来存储每一次的相对位移,对每次检查只需要遍历这个 ...

  4. Linux的yum源配置总结

    本文总结归纳了一系列Linux系统的各种yum配置,虽然不一定是标准配置,但都是自己曾真实测过可用的. 1.RHEL6 本地 yum源配置 2.CentOS6 本地 yum源配置 3.OEL5 本地 ...

  5. npm script 详解,tsc && electron . 直接编译后 运行,非常方便

    最终平时只需要用这个方法就可以了: tsc && electron . ======================================================== ...

  6. ASP.NET Core分布式项目实战(第三方ClientCredential模式调用)--学习笔记

    任务10:第三方ClientCredential模式调用 创建一个控制台程序 dotnet new console --name ThirdPartyDemo 添加 Nuget 包:IdentityM ...

  7. python中两个不同shape的数组间运算规则

    1 前言 声明:本博客讨论的数组间运算是指四则运算,如:a+b.a-b.a*b.a/b,不包括 a.dot(b) 等运算,由于 numpy 和 tensorflow 中都遵循相同的规则,本博客以 nu ...

  8. 基于keras的胶囊网络(CapsNet)

    1 简介 胶囊网络(CapsNet)由 Hinton 于2017年10月在<Dynamic Routing Between Capsules>中提出,目的在于解决 CNN 只能提取特征,而 ...

  9. Vuex和普通全局对象

    Vuex中的核心方法 Vuex是一个专为Vue.js应用程序开发的状态管理模式,其采用集中式存储管理应用的所有组件的状态,并以相应的规则保证状态以一种可预测的方式发生变化.每一个Vuex应用的核心就是 ...

  10. Java 23种设计模式的分类和使用场景

    听说过GoF吧? GoF是设计模式的经典名著Design Patterns: Elements of Reusable Object-Oriented Software(中译本名为<设计模式-- ...