à悟空学院:https://t.cn/Rg3fKJD
学院中有Spring Boot相关的课程!
SpringBoot视频:http://t.cn/A6ZagYTi
Spring Cloud视频:http://t.cn/A6ZagxSR
SpringBoot Shiro视频:http://t.cn/A6Zag7IV
SpringBoot交流平台:https://t.cn/R3QDhU0
SpringData和JPA视频:http://t.cn/A6Zad1OH
SpringSecurity5.0视频:http://t.cn/A6ZadMBe
Sharding-JDBC分库分表实战:http://t.cn/A6ZarrqS
分布式事务解决方案「手写代码」:http://t.cn/A6ZaBnIr
1.1 介绍
以前spring开发需要配置一大堆的xml,后台spring加入了annotaion,使得xml配置简化了很多,当然还是有些配置需要使用xml,比如申明component scan等。
Spring开了一个新的model spring boot,主要思想是降低spring的入门,使得新手可以以最快的速度让程序在spring框架下跑起来。
那么如何写Hello world呢?
(1)新建一个Maven Java 工程
(2)在pom.xml文件中添加Spring Boot Maven依赖
(3)编写启动类
(4)运行程序
1.2 Hello之New
这个步骤很简单,相比大家都会,小编在此为了文档的完整性,稍作简单说明:
首先使用IDE(Eclipse,MyEclipse)工具新建一个Maven工程,可以是Maven Java Project,也可以是Maven Web Project,随便取一个工程名称。我使用的是MyEclipse,工程名是spring-boot-hello1。
1.3 Hello之Maven
第二步,在pom.xml中引入spring-boot-start-parent,spring官方的解释叫什么stater poms,它可以提供dependency management,也就是说依赖管理,引入以后在申明其它dependency的时候就不需要version了,后面可以看到。
<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.3.3.RELEASE</version> </parent>
1.4 Hello之maven web
第三步,因为我们开发的是web工程,所以需要在pom.xml中引入spring-boot-starter-web,spring官方解释说spring-boot-start-web包含了spring webmvc和tomcat等web开发的特性。
<dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> </dependencies>
1.5 Hello之Maven Run Application
如果我们要直接Main启动spring,那么以下plugin必须要添加,否则是无法启动的。如果使用maven 的spring-boot:run的话是不需要此配置的。(我在测试的时候,如果不配置下面的plugin也是直接在Main中运行的。)
<build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin </artifactId> </plugin> </plugins> </build>
1.6 Hello之coding
第四步,真正的程序开始啦,我们需要一个启动类,然后在启动类申明让spring boot自动给我们配置spring需要的配置,比如:@SpringBootApplication,为了可以尽快让程序跑起来,我们简单写一个通过浏览器访问hello world字样的例子:
@RestController @SpringBootApplication public class App { @RequestMapping("/") public String hello(){ return "Hello world!"; } public static void main(String[] args) { SpringApplication.run(App.class, args); } }
其中@SpringBootApplication申明让spring boot自动给程序进行必要的配置,等价于以默认属性使用@Configuration,@EnableAutoConfiguration和@ComponentScan
@RestController返回json字符串的数据,直接可以编写RESTFul的接口;
1.7 Hello之Run
第五步,就是运行我们的Application了,我们先介绍第一种运行方式。第一种方式特别简单:右键Run As -> Java Application。之后打开浏览器输入地址:http://127.0.0.1:8080/ 就可以看到Hello world!了。第二种方式右键project – Run as – Maven build – 在Goals里输入spring-boot:run ,然后Apply,最后点击Run。
1.8 Hello之Error
顺利的情况下当然是皆大欢喜了,但是程序吧往往会给你开个小玩笑。那么我们要注意什么呢?主要是jdk的版本之类的,请看官方说明:
【Spring Boot 系列博客】
【视频&交流平台】
à悟空学院:https://t.cn/Rg3fKJD
学院中有Spring Boot相关的课程!
SpringBoot视频:http://t.cn/A6ZagYTi
Spring Cloud视频:http://t.cn/A6ZagxSR
SpringBoot Shiro视频:http://t.cn/A6Zag7IV
SpringBoot交流平台:https://t.cn/R3QDhU0
SpringData和JPA视频:http://t.cn/A6Zad1OH
SpringSecurity5.0视频:http://t.cn/A6ZadMBe
Sharding-JDBC分库分表实战:http://t.cn/A6ZarrqS
分布式事务解决方案「手写代码」:http://t.cn/A6ZaBnIr
微信公众号「SpringBoot」最近更新:
206. Spring Boot 2.0 Swagger2:使用
205. Spring Boot 2.0 Swagger2:初识Swagger
当要离开的时候,我却动情了
205. jetcache:你需要知道的小技巧
204. jetcache:在Spring Boot中怎么玩?
遇见阿里,遇见自己
203. 阿里jetcache
202. 阿里Pandora Boot
微信公众号赞赏功能升级了,真的假的?
《喜剧之王》「我养你啊」之人生选择
201. Spring Boot JNDI:Spring Boot中怎么玩JNDI
510阿里日,马老师献上最走心、最科技范儿证婚词~
200. Spring Boot JNDI:在Tomcat中怎么玩JNDI?
199. Spring Boot JNDI:这是虾米?
Spring Boot 数据库迁移系列
Spring Boot葵花宝典:初露锋芒:MyBatis insert异常 Parameter 'name' not found
198. Spring Boot Flyway工作原理
21天习惯养成法则
197. Spring Boot 2.0数据库迁移:Liquibase
196. Spring Boot 数据库迁移:Liquibase
195. Spring Boot 2.0数据库迁移:Flyway
194. Spring Boot 数据库迁移:Flyway
193. Spring Boot 数据库迁移:概述
搜索「springboot」或者扫描以下二维码即可关注:
历史章节:
第一章 快速开始
1、Spring Boot之Hello World
2、Spring Boot之Hello World访问404
第二章 Spring Boot之JSON
1、spring boot返回json数据
2、Spring Boot完美使用FastJson解析JSON数据
第三章 Spring Boot热部署
1、Spring Boot热部署(springloader)
2、springboot + devtools(热部署)
第四章 Spring Boot数据库
1、Spring Boot JPA/Hibernate/Spring Data概念
2、Spring Boot JPA-Hibernate
3、Spring Boot Spring Data JPA介绍
4、Spring Boot JdbcTemplate
5、Spring Boot集成MyBatis
第五章 web开发
1、全局异常捕捉
2、配置server信息
3、spring boot使用thymeleaf
4、Spring Boot 使用freemarker
5、Spring Boot添加JSP支持
第六章 定时任务
1、Spring Boot定时任务
2、Spring Boot 定时任务升级篇(动态修改cron参数)
3、Spring Boot 定时任务升级篇(动态添加修改删除定时任务)
4、Spring Boot 定时任务升级篇(集群/分布式下的定时任务说明)
5、Spring Boot Quartz介绍
6、Spring Boot Quartz在Java Project中使用
7、Spring Boot 集成Quartz普通使用
8、Spring Boot 集成Quartz升级版
9、Spring Boot 集成Quartz二次升级版
10、Spring Boot 集成Quartz-Job如何自动注入Spring容器托管的对象
第七章 Spring Boot MyBatis升级篇
1、Spring Boot MyBatis升级篇-注解
2、Spring Boot MyBatis升级篇-注解-自增ID
3、Spring Boot MyBatis升级篇-注解-增删改查
4、Spring Boot MyBatis升级篇-注解-分页查询
5、Spring Boot MyBatis升级篇-注解-分页PageHelper不生效
6、Spring Boot MyBatis升级篇-注解- mybatic insert异常:BindingException: Parameter 'name' not found
7、Spring Boot MyBatis升级篇-注解- #和$符号特别篇
8、Spring Boot MyBatis升级篇-注解-@Result
9、Spring Boot MyBatis升级篇-注解-动态SQL(if test)-方案一:<script>
10、Spring Boot MyBatis升级篇-注解-动态SQL(if test)-方案二:@Provider
11、Spring Boot MyBatis升级篇-注解-动态SQL-参数问题
12、Spring Boot MyBatis升级篇-注解-特别篇:@MapperScan和@Mapper
13、Spring Boot MyBatis升级篇-XML
14、Spring Boot MyBatis升级篇-XML-自增ID
15、Spring Boot MyBatis升级篇-XML-增删改查
16、Spring Boot MyBatis升级篇-XML-分页查询
17、Spring Boot MyBatis升级篇-XML-分页PageHelper不生效
18、Spring Boot MyBatis升级篇-XML-动态SQL(if test)
19、Spring Boot MyBatis升级篇-XML-注解-初尝试
20、Spring Boot MyBatis升级篇- pagehelper替换为pagehelper-spring-boot-starter
第八章 Spring Boot 知识点1
1、Spring Boot 拦截器HandlerInterceptor
2、Spring Boot启动加载数据CommandLineRunner
3、Spring Boot环境变量读取和属性对象的绑定
4、Spring Boot使用自定义的properties
5、Spring Boot使用自定义的properties
6、Spring Boot使用@SpringBootApplication
7、Spring Boot 监控和管理生产环境
第十章 Spring Boot 打包部署
1、Spring Boot打包部署((提供Linux的sh文件))
第十一章 Spring Boot 日志
1、spring boot日志—理论
2、Spring Boot日志-logback
3、Spring Boot日志-log4j2
更多查看博客: http://412887952-qq-com.iteye.com/
相关推荐
从零开始学Spring Boot,没有积分的可以...(1)spring boot起步之Hello World【从零开始学Spring Boot】: http://412887952-qq-com.iteye.com/blog/2291500 (2)Spring Boot返回json数据【从零开始学Spring Boot】 ...
从零开始学Spring Boot.pdf从零开始学Spring Boot.pdf从零开始学Spring Boot.pdf从零开始学Spring Boot.pdf从零开始学Spring Boot.pdf从零开始学Spring Boot.pdf从零开始学Spring Boot.pdf从零开始学Spring Boot.pdf...
Spring Boot 学习示例 Spring Boot 2.0 Mysql 5.6 ...spring-boot-helloworld:Spring Boot 3.0 Hello World Test 单元测试示例 spring-boot-scheduler:Spring Boot 3.0 定时任务 scheduler 使用示例 .....
This book will help you understand what Spring Boot is, how Spring Boot helps you build Spring-based applications quickly and easily, and the inner workings of Spring Boot using easy-to-follow ...
Pro Spring Boot is your authoritative hands-on practical guide for increasing your Spring Framework-based enterprise Java and cloud application productivity while decreasing development time using the...
从零开始学Spring Boot。是学习spring Boot的起步资料!!
spring-boot-helloWorld:spring-boot的helloWorld版本 spring-boot-mybaits-annotation:注解版本 spring-boot-mybaits-xml:xml配置版本 spring-boot-mybatis-mulidatasource:springboot+mybatis多数据源最简解决...
NULL 博文链接:https://412887952-qq-com.iteye.com/blog/2299732
Apress.Beginning.Spring.Boot.2.pdfApress.Beginning.Spring.Boot.2.pdfApress.Beginning.Spring.Boot.2.pdfApress.Beginning.Spring.Boot.2.pdfApress.Beginning.Spring.Boot.2.pdf
Spring Boot 最佳实践.pdf Spring Boot 最佳实践.pdf Spring Boot 最佳实践.pdf Spring Boot 最佳实践.pdf Spring Boot 最佳实践.pdf Spring Boot 最佳实践.pdf
Pro Spring Boot is your authoritative hands-on practical guide for increasing your Spring Framework-based enterprise Java and cloud application productivity while decreasing development time using the...
Spring Boot学习笔记-------(二)spring boot入门,配套例子代码,博客地址:https://blog.csdn.net/huaya1127/article/details/104130300
博客示例代码,Spring boot 自学笔记(一) hello world 代码
Beginning Spring Boot 2 Beginning Spring Boot 2 Beginning Spring Boot 2
NULL 博文链接:https://412887952-qq-com.iteye.com/blog/2293846
spring-boot-config-yaml.jarspring-boot-config-yaml.jarspring-boot-config-yaml.jarspring-boot-config-yaml.jarspring-boot-config-yaml.jarspring-boot-config-yaml.jarspring-boot-config-yaml.jarspring-boot...
赠送jar包:spring-boot-autoconfigure-2.3.12.RELEASE.jar; 赠送原API文档:spring-boot-autoconfigure-2.3.12.RELEASE-javadoc.jar; 赠送源代码:spring-boot-autoconfigure-2.3.12.RELEASE-sources.jar; 赠送...