1、Spring Boot简介
- 简化Spring应用开发的一个框架。
- 整个Spring技术栈的一个大整合。
- J2ee开发的一站式解决方案
2、微服务
- 微服务是一种架构风格。
- 一个应用是一组小型服务。可以通过http的方式进行互通。
- 微服务:每一个功能元素最终都是一个可独立替换和独立升级的软件单元。
3、环境
- jdk13(1.7+)
- maven3.6.3(3.x)
- IDEA2019.3.3
- SpringBoot1.5.9.RELEASE
4、配置
1、MAVEN设置
maven-> conf->settings.xml配置文件中< profiles>标签中加一下配置:
<profiles>
<profile>
<id>jdk-13</id>
<activation>
<activeByDefault>true</activeByDefault>
<jdk>13</jdk>
</activation>
<properties>
<maven.compiler.source>13</maven.compiler.source>
<maven.compiler.target>13</maven.compiler.target>
<maven.compiler.compilerVersion>13</maven.compiler.compilerVersion>
</properties>
</profile>
</profiles>
2、IDEA设置(根据版本设置)
5、Spring Boot HelloWorld
功能:浏览器发送hello请求,服务器接受请求并处理,响应HelloWorld字符串。
1、创建一个maven工程;(jar)(也可在官网自动构建)
2、导入SpringBoot依赖(可加入以下依赖也可在官网自动构建下载项目)
- < parent>父项目
- spring-boot-starter:spring-boot场景启动器,导入web模块正常于宁所依赖的组件
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.9.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
3、编写主程序
4、编写controller
5、启动SpringBoot(在main那块启动)
6、浏览器输入网址(http://localhost:8080/hello)完成
6、简化部署
<!-- 这个插件可以将应用打包成一个可执行的jar包-->
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
命令行进入这个jar包,使用命令:java -jar (文件名)即可运行。