一、环境

1.1、Idea 2020.1

1.2、JDK 1.8

二、目的

初识Spring Boot

三、步骤

3.1、点击File -> New Project -> Spring Initializer,点击next

 

3.2、在对应地方修改自己的项目信息

3.3、修改后如下,点击next

3.4、选择Web依赖,选中Spring Web。可以选择Spring Boot版本,本次默认为2.2.6,点击Next

3.5、编辑工程名和项目路径,确定后点击Finish完成

 

3.6、完成新建工程

 

四、代码分析

 

4.1、运行项目 执行SpringBootBeginHelloApplication下的main方法

 

4.2、测试运行

浏览器访问
 
显示结果如下,表示该web项目正常启动

4.3、新增测试接口

新建包controller,然后建立HelloController类,具体代码如下:
 package org.ouyushan.springboot.begin.controller;

 import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; /**
* @Description
* @Author ouyushan
* @Email ouyushan@hotmail.com
* @Date 2020/4/27
*/ @RestController
@RequestMapping("/springboot")
public class HelloController { @GetMapping("/hello")
public String hello() {
return "Hello,Spring Boot!";
} }

4.4、新接口测试

再次启动程序后浏览器访问:
 
接口请求返回如下:
 <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.6.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>org.ouyushan</groupId>
<artifactId>spring-boot-begin-hello</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>spring-boot-begin-hello</name>
<description>Hello project for Spring Boot</description> <!--指定jdk版本-->
<properties>
<java.version>1.8</java.version>
</properties> <dependencies>
<!--指定spring boot web依赖-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency> <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies> <build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build> </project>

五、知识点

5.1、spring boot 项目可通过以下方式指定jdk版本

     <!--指定jdk版本-->
<properties>
<java.version>1.8</java.version>
</properties>

5.2、spring boot 端口默认是8080

Spring boot Sample 001之spring-boot-begin-hello的更多相关文章

  1. Spring boot Sample 012之spring-boot-web-upload

    一.环境 1.1.Idea 2020.1 1.2.JDK 1.8 二.目的 spring boot 整合web实现文件上传下载 三.步骤 3.1.点击File -> New Project -& ...

  2. Spring boot Sample 0010之spring-boot-web-freemarker

    一.环境 1.1.Idea 2020.1 1.2.JDK 1.8 二.目的 spring boot 整合freemarker模板开发web项目 三.步骤 3.1.点击File -> New Pr ...

  3. Spring boot Sample 009之spring-boot-web-thymeleaf

    一.环境 1.1.Idea 2020.1 1.2.JDK 1.8 二.目的 spring boot 整合thymeleaf模板开发web项目 三.步骤 3.1.点击File -> New Pro ...

  4. Spring boot Sample 006之spring-boot-custom-servlet

    一.环境 1.1.Idea 2020.1 1.2.JDK 1.8 二.步骤 2.1.点击File -> New Project -> Spring Initializer,点击next 2 ...

  5. Spring boot Sample 005之spring-boot-profile

    一.环境 1.1.Idea 2020.1 1.2.JDK 1.8 二.目的 通过yaml文件配置spring boot 属性文件 三.步骤 3.1.点击File -> New Project - ...

  6. Spring Boot (五)Spring Data JPA 操作 MySQL 8

    一.Spring Data JPA 介绍 JPA(Java Persistence API)Java持久化API,是 Java 持久化的标准规范,Hibernate是持久化规范的技术实现,而Sprin ...

  7. Spring 5.x 、Spring Boot 2.x 、Spring Cloud 与常用技术栈整合

    项目 GitHub 地址:https://github.com/heibaiying/spring-samples-for-all 版本说明: Spring: 5.1.3.RELEASE Spring ...

  8. spring cloud教程之使用spring boot创建一个应用

    <7天学会spring cloud>第一天,熟悉spring boot,并使用spring boot创建一个应用. Spring Boot是Spring团队推出的新框架,它所使用的核心技术 ...

  9. Spring Boot——2分钟构建spring web mvc REST风格HelloWorld

    之前有一篇<5分钟构建spring web mvc REST风格HelloWorld>介绍了普通方式开发spring web mvc web service.接下来看看使用spring b ...

随机推荐

  1. Python库的安装与查看

    安装库:    Step1:  win+r键打开此页面,并输入cmd     Step2 :键入cmd并点击确定    Step3 :键入语句:“ pip install 库名 “ 回车即可 这样库就 ...

  2. High Card Low Card G(田忌赛马进阶!!)

    传送门 \(首先一定要明确一个观点,不然会完全没有思路\) \(\bullet\)\(由于前半段大的更优,后半段小的更优.\) \(\bullet\)\(所以,\)Bessie\(一定会在前(n/2) ...

  3. SpringBoot:整合Shiro

    目录 1.Shiro简介 1.1.什么是Shiro? 1.2.有哪些功能 1.3.Shiro架构(外部) 1.4.Shiro架构(内部) 2.HelloWorld 3.Shiro整合Spring Bo ...

  4. 王颖奇 201771010129《面向对象程序设计(java)》第八周学习总结

    实验六 接口的定义与使用 实验时间 2018-10-18 1.实验目的与要求 (1) 掌握接口定义方法: (2) 掌握实现接口类的定义要求: (3) 掌握实现了接口类的使用要求: (4) 掌握程序回调 ...

  5. 近期总结的一些Java基础

    1.面向过程:当需要实现一个功能的时候,每一个过程中的详细步骤和细节都要亲力亲为. 2.面向对象:当需要实现一个功能的时候,不关心详细的步骤细节,而是找人帮我做事. 3.类和对象的关系:   a-类是 ...

  6. LeetCode--Array--Remove Element && Search Insert Position(Easy)

    27. Remove Element (Easy)# 2019.7.7 Given an array nums and a value val, remove all instances of tha ...

  7. 明解JAVA 第三章答案

    练习3-1 package candle1220; import java.util.Scanner; public class Nightwatch { public static void mai ...

  8. 想要年薪百万,阿里Sentinel支持RESTful接口都搞不定?

    最近正准备用阿里Sentinel,发现RESTful接口支持的不是很好.有些童鞋可能对Sentinel不是很了解,我们先简单介绍一下. Sentinel简介 Sentinel是一套阿里巴巴开源的流量防 ...

  9. YOLOV4在linux下训练自己数据集(亲测成功)

    最近推出了yolo-v4我也准备试着跑跑实验看看效果,看看大神的最新操作 这里不做打标签工作和配置cuda工作,需要的可以分别百度搜索   VOC格式数据集制作,cuda和cudnn配置 我们直接利用 ...

  10. vue相关环境搭建一条龙

    前言 如题,基于很多朋友对于环境配置及搭建存在疑问或者不熟悉的情况,因此整理一篇完整的环境搭建说明,在此默认各位到手的电脑是需要从0开始配置环境.  nvm的安装 很多同学过去可能安装node都是直接 ...