当前位置 博文首页 > java_bird:Spring boot简单入门学习
? ? ?Spring boot简单入门学习
? ? ? ? ?最近公司所有的项目架构都升级了,思想采用了微服务的思想,技术架构采用了spring cloud,虽然开始了边学边用的阶段,以及踩到了不少的坑,但是里边的原理以及一些高级应用还是不清楚,而正要进一步学习spring cloud的时候发现了spring cloud是基于spring boot的,于是乎又转头去了解了下spring boot是个什么东东。
1.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.
You can use Spring Boot to create Java applications that can be started using java -jar or more traditional war deployments. We also provide a command line tool that runs “spring scripts”.
Our primary goals are:
Provide a radically faster and widely accessible getting started experience for all Spring development.
Be opinionated out of the box, but get out of the way quickly as requirements start to diverge from the defaults.
Provide a range of non-functional features that are common to large classes of projects (e.g. embedded servers, security, metrics, health checks, externalized configuration).
Absolutely no code generation and no requirement for XML configuration.
大意如下:
Spring Boot可以轻松创建可以“运行”的独立的,生产级的基于Spring的应用程序。我们对Spring平台和第三方图书馆有一个看法,所以你可以从最开始的时候开始。大多数Spring Boot应用程序需要很少的Spring配置。
您可以使用Spring Boot创建可以使用java -jar 或更多传统战争部署的Java应用程序。我们还提供一个运行“spring脚本”的命令行工具。
我们的主要目标是:
为所有的Spring开发提供一个更快,更广泛的入门体验。
被开除箱子的意见,但随着需求开始偏离默认值而迅速脱离出来。
提供大量项目(例如嵌入式服务器,安全性,指标,健康检查,外部化配置)通用的一系列非功能特性。
绝对没有代码生成,也不需要XML配置
了解了spring boot大致是干嘛的了,那么我们可以做一个简单的小例子来体验了一把了,就做一个简单的controller访问的helloword
2.创建一个简单的helloword
整体项目的目录结构如下图所示:
2.1 ?创建一个maven项目,pom.xml如下所示(此部分可将jpa与hibernate部分引用去掉,目前用不到,后续连接数据库的时候会用到)
4.0.0
com.zxl
sprintboot-examples
1.0-SNAPSHOT
org.springframework.boot
spring-boot-starter-parent
1.5.4.RELEASE
org.springframework.boot
spring-boot-starter-data-jpa
org.springframework.boot
spring-boot-starter-web
org.hibernate
hibernate-core
org.hsqldb
hsqldb
org.springframework.boot
spring-boot-starter-test
test
mysql
mysql-connector-java
org.springframework.boot
spring-boot-maven-plugin
cs