springboot官网(springboot框架的优点)

本文目录
- springboot框架的优点
- springboot框架的理解
- spring 官网为什么都是spring boot 没有spring
- 如何用springboot创建maven的依赖工程
- 如何创建一个spring boot框架
- 【每天学点Spring】Spring以及Spring Boot框架知识图谱
springboot框架的优点
1、但是SpringBoot只是个微框架,没有提供相应的服务发现与注册的配套功能,没有外围监控集成方案,没有外围安全管理方案,所以在微服务架构中,还需要SpringCloud来配合一起使用。
2、由Pivotal团队提供的全新框架,其设计目的是用来简化新Spring应用的初始搭建以及开发过程。该框架使用了特定的方式来进行配置,从而使开发人员不再需要定义样板化的配置。
3、因为SSM是一个WEB使用框架,覆盖整个使用层,而springboot可以看作是一个启动、配置、快速开发的辅助框架,是针对微服务的。
4、低成本高效率。springboot和vue可以实现模块化、组件化、可插拔的前后端分离架构敏捷开发框架,可用于快速搭建前后端分离后台管理系统,实现简化开发、提升开发效率的经济方面的目的。
5、详情如下:官网的解释Spring在官方首页是这么说的:说使用SpringBoot可以构造任何东西,SpringBoot是构造所有基于Spring的应用程序的起点,SpringBoot在于通过最少的配置为你启动程序。
6、丰富的工具链为SpringBoot的推广带来了利好。SpringBoot的工具链主要来自于两个方面:1)原有Spring积累的工具链;2)SpringMVC或者其他REST框架使用HTTP协议,使得HTTP丰富的工具成为SpringBoot天然的资源。
springboot框架的理解
详情如下:
1.官网的解释 Spring在官方首页是这么说的:说使用SpringBoot可以构造任何东西,SpringBoot是构造所有基于Spring的应用程序的起点,SpringBoot在于通过最少的配置为你启动程序。
2.我的理解 SpringBoot是Spring开源项目的一个子项目,是Spring组件的一站式解决发案,其目的是简化Spring应用的初始搭建和开发过程。
3.SpringBoot的优缺点 其实就是变得简单,快捷,方便,我们以前自己搭建一个Spring Web项目是不是需要配置web.xml,加载Spring和SpringMvc,在配置数据库连接.配置Spring事务,
spring 官网为什么都是spring boot 没有spring
Spring是一个大的框架,SpringBoot只是Spring框架中的一部分,用来简化配置
官网上都是Spring啊,你去Project里看,SpringBoot只是一个而已
如何用springboot创建maven的依赖工程
最近公司运用springboot构建项目,确实比ssh搭建要快很多。springboot官方学习网站
1.首先要下载maven,用maven管理项目很方便,下载完maven配置好环境,maven我就不细说了。
2.创建一个maven项目,pom.xml文件里面写这些:
《modelVersion》4.0.0《/modelVersion》
《groupId》springboot《/groupId》
《artifactId》testSpringBoot《/artifactId》
《version》0.0.1-SNAPSHOT《/version》
《name》testSpringBoot《/name》
《packaging》jar《/packaging》
《!-- 继承父包 --》
《parent》
《groupId》org.springframework.boot《/groupId》
《artifactId》spring-boot-starter-parent《/artifactId》
《version》1.1.3.RELEASE《/version》
《relativePath》《/relativePath》
《/parent》
《!-- spring-boot的web启动的jar包 --》
《dependencies》
《dependency》
《groupId》org.springframework.boot《/groupId》
《artifactId》spring-boot-starter-web《/artifactId》
《/dependency》
《!--jpa的jar包 ,操作数据库的,类似hibernate--》
《dependency》
《groupId》org.springframework.boot《/groupId》
《artifactId》spring-boot-starter-data-jpa《/artifactId》
《/dependency》
《!--mysql驱动--》
《dependency》
《groupId》mysql《/groupId》
《artifactId》mysql-connector-java《/artifactId》
《/dependency》
《!--thymeleaf模板jar,是很不错的html数据传递取值,类似jsp的jstl--》
《dependency》
《groupId》org.springframework.boot《/groupId》
《artifactId》spring-boot-starter-thymeleaf《/artifactId》
《/dependency》
《/dependencies》
《!--maven的插件--》
《build》
《plugins》
《plugin》
《groupId》org.springframework.boot《/groupId》
《artifactId》spring-boot-maven-plugin《/artifactId》
《/plugin》
《/plugins》
《!-- 配置java版本 不配置的话默认父类配置的是1.6--》
《pluginManagement》
《plugins》
《plugin》
《artifactId》maven-compiler-plugin《/artifactId》
《configuration》
《source》1.7《/source》
《target》1.7《/target》
《/configuration》
《/plugin》
《/plugins》
《/pluginManagement》
《/build》
《/project》
3.创建的文件目录如图:
4.在com.boot(即最外层目录文件)下写一个如下main方法:
package com.boot;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
@Configuration
@EnableAutoConfiguration
@ComponentScan
public class Application {
public static void main(String args) {
SpringApplication.run(Application.class, args);
}
}
5.在com.boot.web下创建一个类如下:
package com.boot.web;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
public class MainController {
// @RequestMapping("")
// public String index(){
// return "examples/index";
// }
@RequestMapping("/")
@ResponseBody
String home() {
return "Hello World!";
}
}
@RequestMapping @ResponseBody
这两个注解都是springMVC的,不懂得可以看springMVC
6.在resources下增加一个application.properties文件
文件内容如下配置:
spring.datasource.platform=mysql
spring.datasource.url=jdbc:mysql://localhost/springboot?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&autoReconnect=true&failOverReadOnly=false
spring.datasource.username=root
spring.datasource.password=root
spring.datasource.driverClassName=com.mysql.jdbc.Driver
# Advanced configuration...
spring.datasource.max-active=50
spring.datasource.max-idle=6
spring.datasource.min-idle=2
spring.datasource.initial-size=6
#create table
spring.jpa.hibernate.ddl-auto=validate
server.port=8080
server.session-timeout=30
server.tomcat.uri-encoding=UTF-8
spring.thymeleaf.prefix=classpath:templates/
spring.thymeleaf.suffix=.html
spring.thymeleaf.mode=HTML5
spring.thymeleaf.encoding=UTF-8
spring.thymeleaf.content-type=text/html
spring.thymeleaf.cache=false
该文件的配置可以参考springboot的官网
该文件的全部参数配置;如下(摘自官网)
# ===================================================================
# COMMON SPRING BOOT PROPERTIES
#
# This sample file is provided as a guideline. Do NOT copy it in its
# entirety to your own application. ^^^
# ===================================================================
# ----------------------------------------
# CORE PROPERTIES
# ----------------------------------------
# SPRING CONFIG (ConfigFileApplicationListener)
spring.config.name= # config file name (default to ’application’)
spring.config.location= # location of config file
# PROFILES
spring.profiles.active= # comma list of active profiles
# APPLICATION SETTINGS (SpringApplication)
spring.main.sources=
spring.main.web-environment= # detect by default
spring.main.show-banner=true
spring.main....= # see class for all properties
# LOGGING
logging.path=/var/logs
logging.file=myapp.log
logging.config= # location of config file (default classpath:logback.xml for logback)
logging.level.*= # levels for loggers, e.g. "logging.level.org.springframework=DEBUG" (TRACE, DEBUG, INFO, WARN, ERROR, FATAL, OFF)
# IDENTITY (ContextIdApplicationContextInitializer)
spring.application.name=
spring.application.index=
# EMBEDDED SERVER CONFIGURATION (ServerProperties)
server.port=8080
# JACKSON (JacksonProperties)
spring.jackson.date-format= # Date format string (e.g. yyyy-MM-dd HH:mm:ss), or a fully-qualified date format class name (e.g. com.fasterxml.jackson.databind.util.ISO8601DateFormat)
spring.jackson.property-naming-strategy= # One of the constants on Jackson’s PropertyNamingStrategy (e.g.
# THYMELEAF (ThymeleafAutoConfiguration)
spring.thymeleaf.prefix=classpath:/templates/
spring.thymeleaf.suffix=.html
spring.thymeleaf.mode=HTML5
spring.thymeleaf.encoding=UTF-8
spring.thymeleaf.content-type=text/html # ;charset=《encoding》 is added
spring.thymeleaf.cache=true # set to false for hot refresh
# FREEMARKER (FreeMarkerAutoConfiguration)
spring.freemarker.allowRequestOverride=false
spring.freemarker.cache=true
spring.freemarker.checkTemplateLocation=true
spring.freemarker.charSet=UTF-8
spring.freemarker.contentType=text/html
spring.freemarker.exposeRequestAttributes=falseshell.ssh.keyPath=
shell.ssh.port=
shell.telnet.enabled= # telnet settings ...
shell.telnet.port=
shell.auth.jaas.domain= # authentication settings ...
shell.auth.key.path=
shell.authwww.meidiyazx.com/sitemap.txtname=
shell.authwww.meidiyazx.com/sitemap.txtpassword=
shell.auth.spring.roles=spring.freemarker.exposeSessionAttributes=false
spring.freemarker.exposeSpringMacroHelpers=false
spring.freemarker.prefix=
spring.freemarker.requestContextAttribute=
spring.freemarker.settings.*=
spring.freemarker.suffix=.ftl
spring.freemarker.templateLoaderPath=classpath:/templates/ # comma-separated list
spring.freemarker.viewNames= # whitelist of view names that can be resolved
# GROOVY TEMPLATES (GroovyTemplateAutoConfiguration)
spring.groovy.template.cache=true
spring.groovy.template.charSet=UTF-8
spring.groovy.template.configuration.*= # See Groovy’s TemplateConfiguration
spring.groovy.template.contentType=text/html
spring.groovy.template.prefix=classpath:/templates/
spring.groovy.template.suffix=.tpl
spring.groovy.template.viewNames= # whitelist of view names that can be resolved
# VELOCITY TEMPLATES (VelocityAutoConfiguration)
spring.velocity.allowRequestOverride=false
spring.velocity.cache=true
spring.velocity.checkTemplateLocation=true
spring.velocity.charSet=UTF-8
spring.velocity.contentType=text/html
spring.velocity.dateToolAttribute=
spring.velocity.exposeRequestAttributes=false
spring.velocity.exposeSessionAttributes=false
spring.velocity.exposeSpringMacroHelpers=false
spring.velocity.numberToolAttribute=
spring.velocity.prefix=
spring.velocity.properties.*=
spring.velocity.requestContextAttribute=
spring.velocity.resourceLoaderPath=classpath:/templates/
spring.velocity.suffix=.vm
spring.velocity.viewNames= # whitelist of view names that can be resolved
# INTERNATIONALIZATION (MessageSourceAutoConfiguration)
spring.messages.basename=messages
spring.messages.cacheSeconds=-1
spring.messages.encoding=UTF-8
# SECURITY (SecurityProperties)
security.user.name=user # login username
security.user.password= # login password
security.user.role=USER # role assigned to the user
security.require-ssl=false # advanced settings ...
security.enable-csrf=false
security.basic.enabled=true
spring.batch.schema= # batch schema to load
# AOP
spring.aop.auto=
# GIT INFO
spring.git.properties= # resource ref to generated git info properties file
7.找到com.boot下的Application以java Application方式启动,然后打开浏览器输入localhost:8080就会出现Hello World!
这样一个简单的web开发就搭建好了。
如何创建一个spring boot框架
ing应用的初始搭建以及开发过程。该框架使用了特定的方式来进行配置,从而使开发人员不再需要定义样板化的配置。
废话不多说,关于spring-boot是什么具体请百度。
***隐藏网址***
1. spring-boot是一个mavan项目,所以其使用的jar包全部是通过maven管理,当然,使用maven也是非常方便的。
首先上我的项目目录结构:
spring-boot打出来的包是一个可执行jar包的状态,使用的是内置的tomcat服务器,所以不需要将项目转成EJB项目。
2.设置pom.xml文件
使用过maven的朋友都知道,maven通过pom文件的依赖来进行管理jar包,所以核心也是这个pom.xml文件
《?xml version="1.0" encoding="UTF-8"?》
***隐藏网址***
***隐藏网址***
《modelVersion》4.0.0《/modelVersion》
《groupId》com.lclc.boot《/groupId》
《artifactId》boot-cache《/artifactId》
《version》0.0.1-SNAPSHOT《/version》
《!-- Inherit defaults from Spring Boot --》
《parent》
《!--Spring Boot基础父类,其中包含了很多必要的jar包,如果不使用父类,则需要自己去依赖这些jars --》
《groupId》org.springframework.boot《/groupId》
《artifactId》spring-boot-starter-parent《/artifactId》
《version》1.1.3.RELEASE《/version》
《/parent》
《dependencies》
《!-- web程序的启动项依赖,通过此依赖可引入内嵌的tomcat等web必须的jars --》
《dependency》
《groupId》org.springframework.boot《/groupId》
《artifactId》spring-boot-starter-web《/artifactId》
《/dependency》
《!-- spring-data-jpa程序的启动项依赖,底层为hibernate实现,若不使用此框架则可以依赖其他的orm框架 --》
《dependency》
《groupId》org.springframework.boot《/groupId》
《artifactId》spring-boot-starter-data-jpa《/artifactId》
《/dependency》
《!-- thymeleaf程序的启动项依赖,spring-boot对thymeleaf模板引擎支持最好,建议模板引擎使用此框架 --》
《dependency》
《groupId》org.springframework.boot《/groupId》
《artifactId》spring-boot-starter-thymeleaf《/artifactId》
《/dependency》
《!-- mysql依赖,使用spring-data-jpa需要指定一个数据库方言,用于连接数据库,即mysql驱动 --》
《dependency》
《groupId》mysql《/groupId》
《artifactId》mysql-connector-java《/artifactId》
《/dependency》
《/dependencies》
《dependencyManagement》
《dependencies》
《/dependencies》
《/dependencyManagement》
《build》
《plugins》
《!-- 通过maven构建的插件 --》
《plugin》
《groupId》org.springframework.boot《/groupId》
《artifactId》spring-boot-maven-plugin《/artifactId》
《/plugin》
《/plugins》
《/build》
《!-- 仓库,使用spring-boot RELEASE版本需要这些 --》
《repositories》
《repository》
《id》spring-snapshots《/id》
***隐藏网址***
《snapshots》
《enabled》true《/enabled》
《/snapshots》
《/repository》
《repository》
《id》spring-milestones《/id》
***隐藏网址***
《/repository》
《/repositories》
《pluginRepositories》
《pluginRepository》
《id》spring-snapshots《/id》
***隐藏网址***
《/pluginRepository》
《pluginRepository》
《id》spring-milestones《/id》
***隐藏网址***
《/pluginRepository》
《/pluginRepositories》
《/project》
pom.xml
3.使用maven update 下载jar包
4.由于我们使用了thymeleaf引擎,此引擎需要一个templates文件夹来存放静态页面,以便进行跳转前台。
所以在resources下添加此文件夹并加入一个默认的页面index.html(注:此文件夹下必须有一个html页面,否则thymeleaf启动项会抛异常)
5.编写application.properties
这个配置文件是对spring-boot的一些配置,spring-boot通过此文件对集成在其中的一些框架进行配置。由我的项目结构可以看出,我有两个application.properties文件:
application.properties:主配置文件,spring-boot直接读取这个文件。注:配置文件必须放在resources下,即放在项目根目录下。
application-dev.properties:开发环境配置文件,这个是我的开发环境的配置文件,为了简化一些开发,所以需要一些与部署环境不同的配置,比如页面缓存之类的。此文件通过application.properties的spring.profiles.active属性进行配置读取。
上两个文件的代码:
首先是application.properties:
# PROFILES
## dev | prod | test
spring.profiles.active=dev
# EMBEDDED SERVER CONFIGURATION (ServerProperties)
server.port=8080
server.session-timeout=30
server.context-path=
server.tomcat.max-threads=0
server.tomcat.uri-encoding=UTF-8
# THYMELEAF (ThymeleafAutoConfiguration)
spring.thymeleaf.encoding=UTF-8
# DataSource
spring.datasource.initialize=false
spring.datasource.test-on-borrow=false
spring.datasource.test-on-return=false
spring.datasource.test-while-idle=true
spring.datasource.max-wait-millis=30000
spring.datasource.validation-query=SELECT 1
spring.datasource.time-between-eviction-runs-millis=20000
spring.datasource.min-evictable-idle-time-millis=28700
application.properties
然后是application-dev.properties:
#page cache
spring.thymeleaf.cache=false
# DATASOURCE
spring.datasource.platform=mysql
spring.datasource.url=jdbc:mysql://localhost/test_development?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true
spring.datasource.username=root
spring.datasource.password=123456
spring.datasource.driverClassName=com.mysql.jdbc.Driver
spring.datasource.max-active=5
spring.datasource.max-idle=2
spring.datasource.min-idle=1
spring.datasource.initial-size=1
spring.datasource.initialize=false
# JPA
spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=true
spring.jpa.properties.hibernate.format_sql=false
spring.jpa.properties.hibernate.use_sql_comments=true
application-dev.properties
6.于是配置便完成了,现在看怎么使用spring-boot进行启动一个web程序
spring-boot打的包是一个可执行的jar包,当然也可以打成可执行的war包,启动服务器就完全不需要像以前一样弄一个tomcat进行启动了,完全是java application进行启动
通过一个启动文件的main方法
@Configuration
@EnableAutoConfiguration
@ComponentScan
public class Application {
public static void main(String args){
SpringApplication springApplication = new SpringApplication (Application.class);
springApplication.run (args);
}
}
Application.java
【每天学点Spring】Spring以及Spring Boot框架知识图谱
【参考】
***隐藏网址***
***隐藏网址***
***隐藏网址***
Spring框架以及Spring Boot框架当然是Java最火热的框架之一,罗列了一些知识点:
【解释】
看文档 是最最重要的,所以在RoadMap图中,把它放在第一位。
很多时候我们都会忽略这一点,但其实最准确的解释往往是来自于文档。开发人员花了大量时间来写文档,当然是希望对使用者有所帮助,并且Spring的文档写的也非常全面,所以很有必要好好读一读文档。
Spring 官网:***隐藏网址***
Spring Framework文档:***隐藏网址***
从文档首页也能看到Spring框架的分类,所以才说文档很重要:
Spring Boot文档:***隐藏网址***

更多文章:
手机数据线连接电脑只充电怎么办(数据线连接电脑只能充电怎么回事儿)
2026年10月11日 01:00
教资报名ie系列浏览器怎么调(教师资格证报名浏览器提示不是ie浏览器,怎么回事我用的就是ie浏览器)
2026年10月10日 22:50
qq网吧网关共享(QQ网吧网关怎么登陆,QQ网吧的网管要什么怎么管理)
2026年10月10日 21:10
华硕笔记本bios找不到硬盘启动项(华硕笔记本的bios里的boot选项没有硬盘启动项)
2026年10月10日 20:30







