1.springboot:入门程序
一、Spring Boot 简介
官网英文:
Spring Boot makes it easy to create stand-alone, production-grade Spring based Applications that you can “just run”. We take an opinionated view of the Spring platform and third-party libraries so you can get started with minimum fuss. Most Spring Boot applications need very little Spring configuration.
官网中文说法:
Spring引导使您可以轻松地创建独立的、生产级的基于Spring的应用程序,您可以“直接运行”。 我们对Spring平台和第三方库采取了一种固执己见的观点,这样您就可以开始使用最小的忙乱。大多数Spring启动应用程序都需要非常少的Spring配置。
微服务 : 架构风格(服务微化) 一个应用应该是一组小型服务;可以通过HTTP的方式进行互通;
二、环境准备
- jdk1.8:Spring Boot 推荐jdk1.7及以上;
- maven3.x:maven 3.3以上版本;
- IntelliJIDEA2017:IntelliJ IDEA 2017.2.2 x64、STS
- SpringBoot 1.5.9.RELEASE:1.5.9
- 统一环境;
1. 给maven 的settings.xml配置文件的profiles标签添加
<profile><id>jdk‐1.8</id><activation><activeByDefault>true</activeByDefault><jdk>1.8</jdk></activation><properties><maven.compiler.source>1.8</maven.compiler.source><maven.compiler.target>1.8</maven.compiler.target><maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion></properties> </profile>
四、Spring Boot HelloWorld程序
浏览器发送hello请求,服务器接受请求并处理,响应Hello World字符串;
1、创建一个maven工程;(jar)
2、导入spring boot相关的依赖
<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、编写一个主程序;启动Spring Boot应用
/*** @author 超轶绝尘*/ @SpringBootApplication public class SpringBootDemoApplication {public static void main(String[] args) {SpringApplication.run(HelloWorldMainApplication.class, args);} }
4、编写相关的Controller、Service
@Controller public class HelloController {@ResponseBody@RequestMapping("/hello")public String hello(){return "Hello World!";}}
5、运行主程序测试
6、简化部署
<!‐‐ 这个插件,可以将应用打包成一个可执行的jar包;‐‐><build><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring‐boot‐maven‐plugin</artifactId></plugin></plugins> </build>
将这个应用打成jar包,直接使用java -jar的命令进行执行;
五、自动部署与刷新
自动部署
为了让开发更加得心应手,我们进一步优化IDE,使得Web应用可以自动重启,页面内容修改时网页可以自动刷新,这可以极大地提高我们的开发体验和开发效率。
为了让Spring Boot在需要重启时,能够自动进行,我们只需要
1、在POM文件中增加以下依赖。
<dependencies><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-devtools</artifactId></dependency> </dependencies>
2.1、设置Intellij IDEA
Settings->Build,Execution,Deployment->Compiler->Build project automatically
注意:这里有两个选择,Default Settings是全部项目默认的,假如你之前已经添加了项目,那么设置完这个后当前项目是不会生效的,那么此时需要设置当前项目的Settings,也是同样的设置路径。
2.2
Linux/Windows:【Ctrl】+【Alt】+【Shift】+【/】
Mac:【Command】+【Alt】+【Shift】+【/】
转载于:https://www.cnblogs.com/guchunchao/p/9880486.html
1.springboot:入门程序相关推荐
- SpringBoot简介、SpringBoot 入门程序搭建、与JDBC、Druid、Mybatis和SpringData JPA的整合
一.SpringBoot 简介: spring boot并不是一个全新的框架,它不是spring解决方案的一个替代品,而是spring的一个封装.所以,你以前可以用spring做的事情,现在用spri ...
- springboot入门程序
(1)设置spring boot的parent <parent> <groupId>org.springframework.boot</groupId> <a ...
- 玩转springboot:thymeleaf模板引擎入门程序
一.前言 常用的模板引擎有:JSP.Velocity.Freemarker.Thymeleaf 但是,Springboot默认是不支持JSP的,默认使用thymeleaf模板引擎.而且,语法更简单,功 ...
- 玩转springboot:入门程序
Spring Boot 入门 一.Spring Boot 简介 官网英文: Spring Boot makes it easy to create stand-alone, production-gr ...
- SpringBoot 入门小程序
SpringBoot 入门小程序CSDN下载 SpringBoot 入门小程序GitHub下载 老规矩,先看项目结构. 有必要参考前面的博客.maven构建web工程 我们构建好maven工程之后,用 ...
- SpringBoot入门(二)——起步依赖
本文来自网易云社区 在前一篇我们通过简单几步操作就生成了一个可以直接运行的Web程序,这是因为SpringBoot代替我们做了许多工作,概括来讲可以分为起步依赖和自动配置.这一篇先来看看起步依赖. 项 ...
- Spring Boot快速搭建入门程序
一.快速搭建入门程序 第一步 新增Spring-Boot-starter-parent依赖[父级项目的web依赖] <parent><groupId>org.springfra ...
- springboot 历史版本文档_乘风破浪,SpringBoot入门
SpringBoot入门篇 前言 在普通的java项目中,大量的xml文件配置起来相当繁琐,导致了开发效率非常低下,整合第三方框架的配置可能会存在冲突问题导致部署效率低,打包方式是将项目打成一个war ...
- SpringBoot入门到精通_第5篇 _SpringBoot Actuator监控
接上一篇:SpringBoot入门到精通_第4篇 _开发三板斧 https://blog.csdn.net/weixin_40816738/article/details/101097161 文章目录 ...
- SpringBoot入门到精通_第1篇 _核心概念
SpringBoot 必知必会 核心精粹 文章目录 一.SpringBoot必知必会 1. 是什么?能做什么? 2. 有哪些特性? 一.SpringBoot必知必会 1. 是什么?能做什么? 是什么? ...
最新文章
- 元素算法Bloom Filter
- Google发布Anthos:Google背书,宣告多集群多云Kubernetes时代已来
- 奥特曼系列ol光元在哪个服务器,奥特曼系列ol光元怎么合理使用
- python- 基础 range方法的使用
- 如何root安卓手机_安卓Root+卡开机画面救砖教程丨以一加手机为例
- C语言里if语句变量作为判断条件,C语言教学(九-上)if else判断语句
- 模拟灰度传感器循迹的程序_PLC编程,实例讲解西门子PLC模拟量编程
- 计算机丢失i4m.dll,ntd.dll难住机器人发烧友
- AndroidStudio_安卓原生开发_在fragment中如何使用Toast_以及SharedPreferences---Android原生开发工作笔记149
- SAR(遥感、卫星) 图像常用数据集
- 中国版Kindle Paperwhite使用评测
- [反汇编练习] 160个CrackMe之016
- 多测师杭州拱墅校区__肖sir__软件测试生命周期(4)
- exports生效 nfs_共享存储Nfs使用
- 数论 —— 逆元与同余式定理
- 学计算机用游戏本好吗,学设计的用什么笔记本好呢
- Apache Avro项目简介
- 微信小程序的重点(重中之重)
- win7离线安装tensorflow-gpu1.13.1
- java-php-python-ssm幼儿园综合管理系统计算机毕业设计
热门文章
- java PageUtil + stream 手动计算List 分页
- 韩顺平 mysql sqlhelper类_(最全)韩顺平jsp购物车源代码(包含数据库)
- 网络协议分析 | 传输层 :史上最全UDP、TCP协议详解,一篇通~
- 京东华为 Java开发历年经典题汇总
- 用Python在Tomcat成功启动后自动打开浏览器访问Web应用
- php 不同时区时间转换,在PHP中将DateTime字符串转换为不同的时区
- 二分法查找c语言程序_C语言的那些经典程序 第十四期
- 单基因gsea_筛到5分的核心基因以后你可以怎么做?
- Linux ubuntu对于cmake的版本更新
- web3 0.2.x 和 1.x.x版本之间的差异