SpringBoot开始微服务架构
来源:互联网 发布:网络上icbc是什么意思 编辑:程序博客网 时间:2024/05/16 19:27
简单记录一下学习过程
记得之前SpringMVC的时候,一大堆XML配置搞得人头大,而现在SpringBoot这种微服务架构越来越流行,与他的简单配置分不开。
先来看看SpringBoot的特点
1.独立创建spring应用
2.内嵌服务器tomcat,jetty无需打包war
3.maven配置极简
4.完全没有xml配置,需要什么配置什么
1.新建一个Maven项目
2.新建Application源文件
内容如下
package cn.byhook.maven;import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.EnableAutoConfiguration;import org.springframework.stereotype.Controller;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.ResponseBody;/** * 作者: byhook * 时间: 2017-06-15 * 描述: */@Controller@EnableAutoConfigurationpublic class Application { @RequestMapping("/") @ResponseBody public String index() { return "Hello World!"; } public static void main(String[] args) throws Exception { SpringApplication.run(Application.class, args); }}
3.编辑pom.xml文件
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>cn.byhook.maven</groupId> <artifactId>MavenSpring</artifactId> <packaging>war</packaging> <version>1.0</version> <name>MavenSpring Maven Webapp</name> <url>http://maven.apache.org</url> <build> <finalName>MavenSpring</finalName> </build> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.5.4.RELEASE</version> </parent> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> </dependencies></project>
4.启动项目
在Application中右键 Run Application即可运行或者在命令行输入
mvn spring-boot:run
参考:
http://projects.spring.io/spring-boot/#quick-start
阅读全文
0 0
- SpringBoot开始微服务架构
- SpringBoot快速构建微服务架构体系
- 基于SpringBoot的微服务架构实践
- 微服务,微架构[一]之springboot[helloWorld]
- 微服务,微架构[二]之springboot集成jdbc
- 微服务,微架构[四]之springboot集成Redis缓存
- springboot微服务架构——搭建入门
- 微服务,微架构[五]之springboot读取properties文件
- 微服务,微架构[六]之springboot集成mybatis
- 微服务,微架构[零]springboot入门介绍
- 微服务,微架构[七]之springboot异常处理
- 微服务,微架构[八]springboot多环境切换profiles
- 微服务,微架构[十]springboot模板页面freemarker
- 微服务,微架构[十一]springboot模板页面velocity
- 微服务,微架构[十一]springboot模板页面thymeleaf
- 微服务,微架构[十二]springboot监听器,过滤器
- 微服务,微架构[十三]springboot集成RabbitMQ
- springboot微服务
- android native service
- 设计模式--单例模式
- 题目二 吝啬的国度
- SRE Google 运维解密--管理
- C++学习笔记之作用域为类的常量和作用域内的枚举
- SpringBoot开始微服务架构
- Android 测试类的使用
- dubbo 视频
- C语言结构体声明的妙用,隐藏结构体内部信息
- Java 位运算(移位、位与、或、异或、非)
- 代码风格
- FZU 2203 单纵大法好
- CSDN机器学习笔记八 梯度下降
- leetcode 504. Base 7