Spring Boot学习笔记
一、Spring Boot入门
1.Spring Boot简介
- 主要作用:简化Spring的开发,免去了SpringMVC各种配置文件的繁琐,并且部署项目不需要打成war
2.微服务
-
2014,Martin Fowler
-
In short, the microservice architectural style is an approach to developing a single application as a suite of small services, each running in its own process and communicating with lightweight mechanisms, often an HTTP resource API. These services are built around business capabilities and independently deployable by fully automated deployment machinery. There is a bare minimum of centralized management of these services, which may be written in different programming languages and use different data storage technologies.
-
每一个应用都被拆解成一组小型服务,服务之间可以交互,通常用HTTP进行;
-
每一个服务都独立部署,可独立升级和替换
3.环境准备
1.IDEA
2.maven
4.Spring Boot HelloWorld
1.新建maven项目
2.配置pom.xml,导入Spring Boot相关依赖
3.编写main函数,用来启动SpringBootApplication
/**
*@SpringBootApplication 标注此函数是一个SpringBootApplication
* */
@SpringBootApplication
public class HelloSpringBoot {
public static void main(String[] args) {
SpringApplication.run(HelloSpringBoot.class,args);
}
}
4.编写Contorller
@Controller
public class HelloController {
@ResponseBody
@RequestMapping("/hello")
public String hello(){
return "Hello World!";
}
}
5.运行 main
浏览器中输入http://localhost:8080/hello ,浏览器即可得到response(“Hello World!”)
6.将项目打成jar包,如下
7.一键部署
上一篇: tomcat地址映射
下一篇: spring boot 学习笔记