创建项目

IDEA / File / New / Project / Spring Initalizr / Next

Group: com.wu            公司官网域名反写
Artifact: helloworld 项目的名字,项目根目录的名称
Version: 0.0.1-SNAPSHOT 当前的版本,SNAPSHOT为开发版,Release为稳定版
Name: helloworld 启动类的类名
Package: com.wu.helloworld 包名
Dependencies: Web / Spring Web 引入 tomcat,dispatcherServlet,xml 等依赖
Developer Tools / Spring Boot DevTools 热部署工具,可选

项目主要文件

程序主入口:

src/main/java/com/wu/helloworld/HelloworldApplication

核心配置文件:

src/main/resources/application.properties

单元测试:

src/test/java/com/wu/helloworld/HelloworldApplicationTests

依赖配置文件:

pom.xml

pom.xml 说明

<!-- 父依赖 -->
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.5.RELEASE</version>
<relativePath/>
</parent> <dependencies>
<!-- web场景启动器 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- springboot单元测试 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<!-- 新版本 spring-boot-starter-test 默认使用 Junit5,需要剔除 vintage 依赖 -->
<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>
<!-- 单元测试插件 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<!-- 跳过单元测试,跳过编译单元测试代码 -->
<skip>true</skip>
<!-- 跳过单元测试,但会编译单元测试代码 -->
<!-- <skipTests>true</skipTests> -->
</configuration>
</plugin>
</plugins>
</build>

编写代码

创建目录:

src/main/java/com/wu/helloworld/controller

src/main/java/com/wu/helloworld/dao

src/main/java/com/wu/helloworld/pojo

src/main/java/com/wu/helloworld/service

# src/main/java/com/wu/helloworld/controller/HelloController

@RestController
@RequestMapping("/hello")
public class HelloController {
@GetMapping("/world")
public String world() {
return "Hello, world!";
}
}

测试运行

执行打包:

Maven Projects / helloworld / Lifecycle / package

打包目录:

target/helloworld-0.0.1-SNAPSHOT.jar

运行程序:

target> java -jar .\helloworld-0.0.1-SNAPSHOT.jar

访问测试:

http://localhost:8080/hello/world

[学习笔记] SpringBoot 之 Helloworld的更多相关文章

  1. Hadoop学习笔记(5) ——编写HelloWorld(2)

    Hadoop学习笔记(5) ——编写HelloWorld(2) 前面我们写了一个Hadoop程序,并让它跑起来了.但想想不对啊,Hadoop不是有两块功能么,DFS和MapReduce.没错,上一节我 ...

  2. Spring MVC 学习笔记1 - First Helloworld by Eclipse【& - java web 开发Tips集锦】

    Spring MVC 学习笔记1 - First Helloworld by Eclipse reference:http://www.gontu.org 1. 下载 Spring freamwork ...

  3. 〖C语言学习笔记 〗(一) HelloWorld

    前言 本文为c基础入门学习笔记 正文 HelloWorld #include <stdio.h> //标准输出流 int main() //每种语言都有一个执行入口,main方法就是其一 ...

  4. 【OpenGL 学习笔记01】HelloWorld演示样例

    <<OpenGL Programming Guide>>这本书是看了忘,忘了又看,赶脚还是把笔记做一做心里比較踏实,哈哈. 我的主题是,好记性不如烂笔头. ========== ...

  5. Java学习笔记1(HelloWorld)

    编写HelloWorld是一种仪式: 1.下载JDK,安装,注意路径中不要存在中文. 2.添加环境变量,加入bin目录 3.写一个文本,内容如下,后缀改成.java,注意文本的名称为HelloWorl ...

  6. Spring学习笔记2:Spring HelloWorld

    1:IntelliJ新建Maven工程 2:pom文件加入Spring依赖 <project xmlns="http://maven.apache.org/POM/4.0.0" ...

  7. Go学习笔记(二):编写 HelloWorld 程序

    //Hello.go代码 package main import "fmt" func main(){ fmt.Printf("Hello, world!This is ...

  8. pulsar学习笔记1:helloworld

    pulsar号称是下一代的消息系统,这二年风光无限,大有干掉kafka的势头,如果想快速体验下,可以按以下步骤在本地搭建一个单机版本:(mac环境+jdk8) 一. 下载 wget https://w ...

  9. Ionic2学习笔记(0):HelloWorld

    作者:Grey 原文地址:http://www.cnblogs.com/greyzeng/p/5529153.html 操作系统: Windows 10 环境配置: Node.js Java SE D ...

随机推荐

  1. 【Linux】【Database】【MySQL】使用percona搭建高可用的MySQL数据库

    1. 简介 1.1. 官方文档: 数据库架构:https://docs.openstack.org/ha-guide/shared-database.html 1.2. 本次使用的的是Percona ...

  2. Spring实现类私有方法测试通用方案

    现实的业务场景中,可能需要对Spring的实现类的私有方法进行测试. 场景描述: 比如XXXService里有 两个函数a.函数b. 而实现类XXXServiceImpl中实现了函数a.函数b,还包含 ...

  3. HTML DOM 对象 - 方法和属性

    一些常用的 HTML DOM 方法: getElementById(id) - 获取带有指定 id 的节点(元素) appendChild(node) - 插入新的子节点(元素) removeChil ...

  4. jQuery全局进行方法扩展

    <!DOCTYPE html><html><head> <meta charset="UTF-8"> <title>01 ...

  5. Spring Cloud Alibaba 整合 Nacos 实现服务配置中心

    在之前的文章 <Nacos 本地单机版部署步骤和使用> 中,大家应该了解了 Nacos 是什么?其中 Nacos 提供了动态配置服务功能 一.Nacos 动态配置服务是什么? 官方是这么说 ...

  6. win10 安装xmemcache及使用

    一.下载链接 链接:https://pan.baidu.com/s/14J6Vc8TBEZeRoMp2MgcydQ 提取码:3q8r 二.安装 安装: memcached -d  install 卸载 ...

  7. 查看MySQL正在执行的线程

    一.使用SQL语句查询正在执行的线程 SHOW PROCESSLIST; 二.使用kill 线程id就可以结束线程(引起数据变化的线程需特别小心) SHOW PROCESSLIST; +------+ ...

  8. TPT Fusion平台升级,AUTOSAR及ViL测试功能重装上线

    TPT简介 TPT是针对嵌入式系统基于模型的测试工具,特别是针对控制系统的软件功能测试.TPT支持众多业内主流的工具平台和测试环境,可以完成V模式要求所有阶段(MiL-SiL-PiL-HiL-ViL) ...

  9. Linux httpd搭建

    Linux 搭建网站 配置网络 1 改对应配置文件 vi /etc/sysconfig/network-scripts/ifcfg-ens32 2 使用命令 nmcli connection add ...

  10. 谷歌protobuf(protocol-buffers)各种开发语言数据类型转换说明

    官方文档:https://developers.google.cn/protocol-buffers/docs/proto proto2 proto3