1. spring boot 2.1.9版本quick start参考文档地址:https://docs.spring.io/spring-boot/docs/2.1.9.RELEASE/reference/html/getting-started-first-application.html#getting-started-first-application-pom

  2. 新建一个Maven项目

  3. pom.xml文件中增加导入依赖

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.9.RELEASE</version>
</parent> <dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>

这时项目上有个小红叉,这是由于项目可能有一些必要的组件没有更新,解决方法如下:

// 在项目上右键,选择Maven->Update Project...
// 可以看到小红叉消失了
  1. 书写启动类
package com.fei;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; /**
* Created by zxf on 2019年10月17日
*/
// @RestController注解是@Controller和@ResponseBody两个注解的组合
@RestController
@EnableAutoConfiguration
public class SpringBootDemoApplication { /**
* 对外提供一个/服务
* @return
*/
@RequestMapping("/")
public String home() {
return "Hello World!";
} // Spring Boot应用启动类
public static void main(String[] args) {
SpringApplication.run(SpringBootDemoApplication.class, args);
}
}
  1. 直接像运行Java程序那样就可以了,然后在浏览器输入http://localhost:8080/访问即可看到Hello world!

  2. 控制台打印的日志信息如下

 .   ____          _            __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.1.9.RELEASE) 2019-10-17 23:27:00.528 INFO 9320 --- [ main] com.fei.SpringBootDemoApplication : Starting SpringBootDemoApplication on Dell-pc with PID 9320 (E:\Developing\workspace-sts\spring-boot-demo\target\classes started by Dell in E:\Developing\workspace-sts\spring-boot-demo)
2019-10-17 23:27:00.542 INFO 9320 --- [ main] com.fei.SpringBootDemoApplication : No active profile set, falling back to default profiles: default
2019-10-17 23:27:02.268 INFO 9320 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2019-10-17 23:27:02.348 INFO 9320 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2019-10-17 23:27:02.352 INFO 9320 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.26]
2019-10-17 23:27:02.568 INFO 9320 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2019-10-17 23:27:02.568 INFO 9320 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1945 ms
2019-10-17 23:27:02.930 INFO 9320 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2019-10-17 23:27:03.190 INFO 9320 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2019-10-17 23:27:03.195 INFO 9320 --- [ main] com.fei.SpringBootDemoApplication : Started SpringBootDemoApplication in 3.371 seconds (JVM running for 5.42)
2019-10-17 23:28:54.760 INFO 9320 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring DispatcherServlet 'dispatcherServlet'
2019-10-17 23:28:54.761 INFO 9320 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'
2019-10-17 23:28:54.771 INFO 9320 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Completed initialization in 10 ms

从日志信息我们可以知道以下信息:

  • 所用Spring Boot的版本为:2.1.9.RELEASE :: Spring Boot :: (v2.1.9.RELEASE)

  • 当前运行的Spring Boot进程PID:with PID 9320

  • 当前应用使用的是内嵌的tomcat,并且运行在8080端口上:o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''

手动创建一个Spring Boot 2.x项目的更多相关文章

  1. 创建一个 Spring Boot 项目,你会几种方法?

    我最早是 2016 年底开始写 Spring Boot 相关的博客,当时使用的版本还是 1.4.x ,文章发表在 CSDN 上,阅读量最大的一篇有 42W+,如下图: 2017 年由于种种原因,就没有 ...

  2. 社区版Intelij IDEA快速创建一个spring boot项目(找不到sping Initializer选项)

    首先作为一个初学spring boot的小白,在学习过程中肯定会遇到各种问题... So,问题出现:在我想快速创建spring boot项目时,却在新建列表中找不到sping Initializer这 ...

  3. eclipse快速创建一个Spring Boot应用

    1,创建一个空的maven项目 2,添加parent <parent> <groupId>org.springframework.boot</groupId> &l ...

  4. spring boot学习01【搭建环境、创建第一个spring boot项目】

    1.给eclipse安装spring boot插件 Eclipse中安装Spring工具套件(STS): Help -> Eclipse Marketplace... 在Search标签或者Po ...

  5. Spring Boot 多模块项目创建与配置 (一) (转)

    Spring Boot 多模块项目创建与配置 (一) 最近在负责的是一个比较复杂项目,模块很多,代码中的二级模块就有9个,部分二级模块下面还分了多个模块.代码中的多模块是用maven管理的,每个模块都 ...

  6. Spring Boot 多模块项目创建与配置 (一)

    最近在负责的是一个比较复杂项目,模块很多,代码中的二级模块就有9个,部分二级模块下面还分了多个模块.代码中的多模块是用maven管理的,每个模块都使用spring boot框架.之前有零零散散学过一些 ...

  7. Spring Boot 多模块项目创建与配置 (转)

    转载:https://www.cnblogs.com/MaxElephant/p/8205234.html 最近在负责的是一个比较复杂项目,模块很多,代码中的二级模块就有9个,部分二级模块下面还分了多 ...

  8. 快速搭建一个Spring Boot + MyBatis的开发框架

    前言:Spring Boot的自动化配置确实非常强大,为了方便大家把项目迁移到Spring Boot,特意总结了一下如何快速搭建一个Spring Boot + MyBatis的简易文档,下面是简单的步 ...

  9. 搭建第一个spring boot项目

    一.开发工具建议使用Spring Tool Suite 下载地址:http://spring.io/tools/sts/all/ 点击versions选择相应的版本下载,解压后直接运行即可. 二.创建 ...

随机推荐

  1. leetcode 590.N-ary Tree Postorder Traversal N叉树的后序遍历

    递归方法 C++代码: /* // Definition for a Node. class Node { public: int val; vector<Node*> children; ...

  2. Spring 缓存切面

    缓存切面:[通知+目标方法调用] 缓存操作执行过程: 1)如果是同步调用[sync=true],则首先尝试从缓存中读取数据,读取到则直接返回: 否则执行目标方法,将结果缓存后返回. 2)如果不是同步调 ...

  3. Leon-ai on WSL

    这几天尝试了下Windows10的WSL,的确是良心产品,虽然还有很多待改进的地方(比如iptabeles之类的功能还未支持). 使用了WSL就避免安装双系统的繁琐,节省很多时间,而且因为是微软自家产 ...

  4. 快速入门分布式消息队列之 RabbitMQ(3)

    目录 目录 前文列表 前言 通道 Channel 一个基本的生产者消费者实现 消费者 生产者 运行结果 应用预取计数 应用 ACK 机制 最后 前文列表 快速入门分布式消息队列之 RabbitMQ(1 ...

  5. 基于Python对象引用、可变性和垃圾回收详解

    基于Python对象引用.可变性和垃圾回收详解 下面小编就为大家带来一篇基于Python对象引用.可变性和垃圾回收详解.小编觉得挺不错的,现在就分享给大家,也给大家做个参考. 变量不是盒子 在示例所示 ...

  6. IntlliJ IDEA 注册码获取或离线破解

    JB 的软件还是挺好用的,建议有钱的话支持正版.. IntelliJ IDEA 有开源版,但是要想玩企业级开发,还是得用收费版. 不管哪种方式,使用前都需要把"0.0.0.0 account ...

  7. cocos2dx基础篇(12) 编辑框之一CCTextFieldTTF

    前面我们讲了精灵贴图.标签.菜单.按钮.感觉似乎少了点什么?UI控件里是不是应该还有一个很重要的控件--编辑框.在手机网游中,启动游戏,过了开场动画后,基本上显示的第一个界面应该就是游戏的登录界面了吧 ...

  8. Django-DRF组件学习-路由学习

    1.路由router 对于视图集ViewSet,我们除了可以自己手动指明请求方式与动作action之间的对应关系外,还可以使用Routers来帮助我们快速实现路由信息. REST framework提 ...

  9. 4.站点克隆wget----隐写术图片----backbox linux

    站点克隆wget sudo bash cd Desktop/Cloned wget -h clear wget -mk https://help.ubuntu.com/ 隐写术图片 想想朋友圈的图片 ...

  10. 针对WordPress站点思路

    一.使用WPscan 1).简介 WPScan是一个扫描 WordPress 漏洞的黑盒子扫描器,它可以为所有 Web 开发人员扫描 WordPress 漏洞并在他们开发前找到并解决问题.我们还使用了 ...