1. Spring Boot 2.x with Get Started

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接: https://blog.csdn.net/hadues/article/details/101110483

Spring Boot 入门导航

0x01 Spring 与Spring Boot

我们知道Spring的出现简化了Java 企业级应用的开发,从最初的依赖注入容器以及灵活的配置方式,经过多年的发展,已经成为功能丰富,生态完整的企业应用开发全栈框架。

Spring 框架提供了如下功能和子系统:

  • Spring Data
  • Spring MVC
  • Spring Security
  • Spring Session
  • Spring Cloud

针对这些功能和子系统,我们往往要在xml中配置很多内容,一不小心很容易配置错误。

Spring 团队意识到这个问题后,就推出了Spring Boot.

Spring Boot 提供了一系列名称以spring-boot-starter 开头的启动器帮我们简化项目的依赖。比如,添加了spring-boot-starter-web 就会自动根据传递依赖将spring-mvc,jackson-json,tomcat等引入,然后根据自动配置扫描classpath 加入的依赖,最后加载该依赖的默认配置。

我们开发常用的启动器有如下几个:

  • spring-boot-starter-web, web 应用开发
  • spring-boot-starter-logging,日志处理
  • spring-boot-starter-jpa, 数据存储管理
  • spring-boot-starter-security, 安全管理
  • spring-boot-starter-data-redis, Redis 数据库集成
  • spring-boot-starter-amqp, 消息中间件集成

点击查看全部的Spring Boot 启动器列表

0x02 如何构建一个Spring Boot 项目

构建一个Spring Boot 项目最流行的有如下三种方式.

2.1 使用 Intellij Idea 构建项目

Intellij Idea 是一款Java开发最强大最智能的IDE集成开发工具。

2.2 使用Spring Tools 4 for Eclipse(简称 STS)构建项目

  • Spring Tools 4 for Eclipse 是Spring 官方团队推出的Java开发集成IDE工具。
  • 对Spring完美支持,开源免费且支持start.spring.io网址构建项目
  • Spring Tools 4 for Eclipse 新版本,该版本不支持部署war到tomcat,Jetty 等外部容器中
  • Spring Tools 3 for Eclipse 旧版本,该版本支持部署war到tomcat,Jetty 等外部容器中

2.3 start.spring.io 在线构建项目

初始化一个Spring Boot 项目,可以使用Spring 官方团队提供的项目生成工具 https://start.spring.io/

0x03 如何安装打包运行一个Spring Boot 项目?

推荐使用我精心配制的settings.xml

3.1 maven 安装依赖

pom.xml 根目录下运行

mvn clean install

3.2 maven 打包

pom.xml根目录下执行

mvn clean package

命令含义:首先清理target文件夹中所有内容,然后打包成*.jar或者*.war输出到target根目录

3.3 maven 运行

pom.xml根目录下执行

java -jar your-app.jar

命令含义: 运行一个*.jar

3.4 jar剖析

解压该jar文件可以看到

  • BOOT-INF\classes 存放编译后的所有Java源码
  • BOOT-INF\lib 项目依赖的Jar包
  • org\springframework\boot\loader Spring Boot 启动时需要的类

0x04 Spring Boot 2.x 学习专栏目录

博文标题 源码下载
1.Spring Boot 2.x with Get Started -
2.Spring Boot 2.x With Customize Banner spring-boot-with-customize-banner-sample
3.Spring Boot 2.x With Customize Properties spring-boot-with-configuration-processor-sample
4. Spring Boot 2.x With lombok -
5. Spring Boot 2.x With Logback spring-boot-with-slf4j-logback-sample
6. Spring Boot 2.x With Apache Log4j2 spring-boot-with-log4j2-sample
7. Spring Boot 2.x With Spring Web MVC spring-boot-with-web-sample
8. Spring Boot 2.x With Static Resources -
9. Spring Boot 2.x With Thymeleaf spring-boot-with-thymeleaf-sample
10.Spring Boot 2.x With JSP spring-boot-with-jsp-sample
11. Spring Boot 2.x With Swagger spring-boot-with-swagger-sample
12. Spring Boot 2.x wtih MyBatis spring-boot-with-mybatis-sample
13. Spring Boot 2.x With Spring for Apache Kafka spring-boot-with-spring-kafka-sample
14. Spring Boot 2.x With Spring Data JPA spring-boot-with-spring-data-jpa-sample

本篇完~

猜你喜欢

转载自blog.csdn.net/hadues/article/details/101110483