目录
3、启动项目(springboot项目有内置的tomcat不需要配置点击main方法即可启动项目)
一、SpringBoot简介
1、springboot是什么
Spring Boot它本身并不提供Spring框架的核心特性以及扩展功能,只是用于快速、敏捷地开发新一代基于Spring框架的应用程序。
也就是说,它并不是用来替代Spring的解决方案,而是和Spring框架紧密结合用于提升Spring开发者体验的工具同时它集成了大量常用的第三方库配置(例如Jackson, JDBC, Mongo, Redis, Mail等等),
Spring Boot应用中这些第三方库几乎可以零配置的开箱即用(out-of-the-box),大部分的Spring Boot应用都
只需要非常少量的配置代码,开发者能够更加专注于业务逻辑
2、特点
①敏捷式开发
②spring boot其实不是什么新的框架,它默认配置了很多框架的使用方式, 就像maven整合了所有的jar包,spring boot整合了所有的框架
③基于Spring框架的一站式解决方案
二、SpringBoot入门
1、创建SpringBoot项目
可以换源(创建项目更快)
2、创建web层
package com.yzq.springboot.demo;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @author 白未
* @site 3185579318
* @company xxx公司
* @create 2022-10-28 19:02
*/
@RestController
public class IndexController {
@RequestMapping("/")
public String index(){
System.out.println("进入测试....");
return "index";
}
}
3、启动项目(springboot项目有内置的tomcat不需要配置点击main方法即可启动项目)
解决没有数据源配置
4、下载properties与yml的文件转换插件
Convert YAML and Properties File
application.properties
# 应用名称
spring.application.name=testspringboot02
# 应用服务 WEB 访问端口
server.port=8081
#下面这些内容是为了让MyBatis映射
#指定Mybatis的Mapper文件
mybatis.mapper-locations=classpath:mappers/*xml
#指定Mybatis的实体目录
mybatis.type-aliases-package=com.zking.testspringboot02.mybatis.entity
转化
选中application.properties右键点击 Convert YAML and Properties File
application.yml
mybatis:
mapper-locations: classpath:mappers/*xml
type-aliases-package: com.zking.testspringboot02.mybatis.entity
server:
port: 8081