Springboot2.0从零开始搭建脚手架(一)-初始化和整合MybatisPlus3.0+

本文介绍了如何从零开始使用SpringBoot2.1搭建项目,包括初始化项目、导入IDE、配置热加载、自定义启动banner、关闭banner打印。接着,文章详细讲解了集成MybatisPlus3.0+的过程,配置数据源,使用MybatisPlus代码生成器生成代码,以及测试接口的编写。通过这些步骤,完成了一个基础的SpringBoot+MybatisPlus项目设置。
摘要由CSDN通过智能技术生成

初始化springboot项目

添加web依赖,基于springboot2.1.3稳定版本
初始化spring boot项目地址 https://start.spring.io/
包名:com.nqmysb.scaffold
在这里插入图片描述

导入IDE

下载项目,我这里使用eclipse ,导入eclipse之后如下图
在这里插入图片描述

编写控制器

写一个控制器,并启动查看结果,这里直接将controller写在入口类

@RestController
@SpringBootApplication
public class SpringbootScaffoldApplication {
   

	public static void main(String[] args) {
   
		SpringApplication.run(SpringbootScaffoldApplication.class, args);
	}
	
	@RequestMapping("/index")
	public String index(String[] args) {
   
		
		System.out.println("hello world");
		
		return "springboot2.0 hello!";
	}

}

验证访问

通过访问浏览器查看结果 http://localhost:8080/index ,浏览器显示和控制台打印正常!
在这里插入图片描述
在这里插入图片描述

热加载配置

在项目pom.xml文件中加入热加载依赖,重新启动,修改代码时项目会自动重启更新项目。

		<!-- hot reload -->
		<dependency>
			  <groupId>org.springframework.boot</groupId>
			  <artifactId>spring-boot-devtools</artifactId>
			  <optional>true</optional>
		</dependency>

自定义启动banner图案

在src/main/recesources下新建一个banner.txt文件,内容如下:佛系程序员

${AnsiColor.BRIGHT_YELLOW}
===================================================================================

 _____  _           _          _    _            _         _   _
 |  __ \| |         | |        | |  | |          | |       | | | |
 | |__) | |__   ___ | |_ ___   | |__| | __ _  ___| | ____ _| |_| |__   ___  _ __
 |  ___/| '_ \ / _ \| __/ _ \  |  __  |/ _` |/ __| |/ / _` | __| '_ \ / _ \| '_ \
 | |    | | | | (_) | || (_) | | |  | | (_| | (__|   < (_| | |_| | | | (_) | | | |
 |_|    |_| |_|\___/ \__\___/  |_|  |_|\__,_|\___|_|\_\__,_|\__|_| |_|\___/|_| |_|


//                          _ooOoo_                               //
//                         o8888888o                              //
//                         88" . "88                              //
//                         (| ^_^ |)                              //
//                      
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值