SpringBoot 概念和起步
一、概念和由来
1、什么是 Spring Boot
Spring Boot 的设计目的是用来简化新Spring应用的初始搭建以及开发过程。该框架使用特定方式来进行配置,从而使开发人员不再需要定义样板化的配置。
Spring Boot 其实不是什么新的框架,它默认配置了很多框架的使用方式。
- 内置Tomcat和Jetty容器
- Starter pom 简化项目配置
- 大型项目的非功能特性,如:安全、指标、健康监测、外部配置等
- 没有代码生成和xml配置文件
2、内置 Servlet Container
- tomcat8 + servelt规范3.1
- jetty9.3+ servelt规范3.1
- undertow1.3+ servelt规范3.1
3、开发调试工具
- SpringBoot DevTools
二、创建 gradle 工程
1、创建 gradle 工程:http://start.spring.io/
你可以通过 Spring Initializr 来创建一个空的项目,也可以手动创建。

2、构建工程
要采用科学上网,否则会慢的让你崩溃的!!
(1)修改gradle下载地址

(2)、使用阿里云的maven库




buildscript {
ext {
springBootVersion = '1.5.7.RELEASE'
}
repositories {
//mavenCentral()
maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/'}
//maven { url "https://repo.spring.io/snapshot" }
//maven { url "https://repo.spring.io/milestone" }
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
group = 'com.tianhe.example.springboot'
version = '0.0.1-SNAPSHOT'
//生成的jar包包名和版本
jar {
baseName = 'HelloGradle'
version = '0.1.0'
}
//设置jdk的版本
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories {
//mavenCentral()
maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/'}
//maven { url "https://repo.spring.io/snapshot" }
//maven { url "https://repo.spring.io/milestone" }
}
[compileJava,compileTestJava,javadoc]*.options*.encoding = "utf-8"
configurations.all {
exclude module: 'slf4j-jcl'
exclude module: 'slf4j-jdk14'
exclude module: 'slf4j-nop'
exclude module: 'slf4j-simple'
exclude module: 'slf4j-log4j12'
exclude module: 'log4j'
exclude module: 'commons-logging'
exclude module: 'commons-logging-api'
}
dependencies {
compile('org.slf4j:slf4j-api:1.7.15') {
force = true
}
compile('org.slf4j:jcl-over-slf4j:1.7.15') {
force = true
}
compile('org.slf4j:log4j-over-slf4j:1.7.15') {
force = true
}
compile('org.slf4j:jul-to-slf4j:1.7.15') {
force = true
}
compile('ch.qos.logback:logback-core:1.1.7') {
force = true
}
compile('ch.qos.logback:logback-classic:1.1.7') {
force = true
}
compile("org.springframework.boot:spring-boot-starter-web")
compile("org.springframework.boot:spring-boot-starter-thymeleaf")
compile("org.springframework.boot:spring-boot-starter-data-jpa")
compile("org.springframework.boot:spring-boot-starter-actuator")
compile('com.fasterxml.jackson.core:jackson-databind:2.7.4')
compile('com.fasterxml.jackson.core:jackson-core:2.7.4')
compile('com.fasterxml.jackson.core:jackson-annotations:2.7.4')
compile('commons-httpclient:commons-httpclient:3.1')
compile('org.htmlparser:htmlparser:1.6')
compile "commons-lang:commons-lang:2.6"
compile "commons-io:commons-io:2.4"
compile "commons-codec:commons-codec:1.5"
runtime("mysql:mysql-connector-java")
testCompile('org.springframework.boot:spring-boot-starter-test')
}
3、前端代码



4、启动应用
在IDE中直接直接执行main方法,然后访问http://localhost:8080即可。
三、附录
1、thymeleaf Exception parsing document: template="xxxx"错误
Thymeleaf模板引擎,遇到不闭合标签会报这个错误,很是蛋疼啊。最后发现是自动生成的meta标签没有关闭,太太坑了。

网上搜来的解决方案:
(1). 添加maven依赖
<dependency>
<groupId>net.sourceforge.nekohtml</groupId>
<artifactId>nekohtml</artifactId>
<version>1.9.22</version>
</dependency>
(2). 更改application.properties属性
spring.thymeleaf.mode=LEGACYHTML5
SpringBoot 概念和起步的更多相关文章
- SpringBoot基础学习(一) SpringBoot概念、简单案例实现、单元测试及热部署讲解
SpringBoot概念 Spring优缺点分析 Spring优点 Spring是Java企业版(Java Enterprise Edition,JEE,也称J2EE)的轻量级代替品,无需开发重量级的 ...
- SpringBoot系列教程起步
本篇学习目标 Spring Boot是什么? 构建Spring Boot应用程序 三分钟开发SpringBoot应用程序 本章源码下载 Spring Boot是什么? spring Boot是由Piv ...
- 关于springboot
概念 Spring的优缺点 1. 优点(AOP和IOC简化开发) Spring是Java企业版(Java Enterprise Edition,JEE,也称J2EE)的轻量级代替品.无需开发重量级的E ...
- Java工程师之SpringBoot系列教程前言&目录
前言 与时俱进是每一个程序员都应该有的意识,当一个Java程序员在当代步遍布的时候,你就行该想到我能多学点什么.可观的是后端的框架是稳定的,它们能够维持更久的时间在应用中,而不用担心技术的更新换代.但 ...
- SpringBoot的基础
概念 Spring的优缺点 1. 优点(AOP和IOC简化开发) Spring是Java企业版(Java Enterprise Edition,JEE,也称J2EE)的轻量级代替品.无需开发重量级的E ...
- SpringBoot教程——检视阅读
SpringBoot教程--检视阅读 参考 SpringBoot教程--一点--蓝本--springboot2.1.1 SpringBoot教程--易百--springboo2.0.5.RELEASE ...
- SpringBoot和微服务
SpringCloud SpringBoot 概念 应用 微服务CAP Consistency(数据强一致性),Availability(服务可用性),Partition-tolerance(分区容错 ...
- springboot依赖
springboot依赖整合 <parent> <groupId>org.springframework.boot</groupId> <artifactId ...
- JPA、Hibernate、Spring data jpa之间的关系,以及和springboot的整合
什么么是JPA? 全称Java Persistence API,可以通过注解或者XML描述[对象-关系表]之间的映射关系,并将实体对象持久化到数据库中. 为我们提供了: 1)ORM映射元数据:JPA支 ...
随机推荐
- 将["a"=1,"b"=2] 转为对象
var obj = {}; var arr = ["a=1","b=2","c=3"]; for (var x in arr){ var s ...
- js中判定this的规则
判定this new绑定:新建对象; var bar = new foo(); 明确绑定(call.apply,bind):指定对象; var bar = foo.call(obj) 隐含绑定:环境对 ...
- python笔记之函数
函数 >>> def funTest(param1): ... 'this is function document string.' #正文需要有缩进 ... return par ...
- parted分区及挂载实战操作大全
个人原创博客,转载请注明,否则要负法律责任 2017-09-29-14:46:25[root@localhost ~]# df -hFilesystem Size Used Avail Use% Mo ...
- c# 根据唯一码,存缓存 实现12小时内 阅读量+1
需求:某一个详细页面需要实现用户 12小时内阅读量+1, 实现思路;得到一个唯一码的机器码,不管是否用户登录了 都有这个码,然后存到缓存里面 最后判断时间+12小时 是否超过当前时间 string ...
- 萌新关于C#委托一点见解
开博第一写C#委托(一个简单的委托) 1.关于委托,一直是学习c#的萌新们的噩梦,小生也是.最近在学委托感觉瞬间被虐成狗,但作为C#中极为重要的一个内容,学好了将会及大地减少我们的代码量,而且这也是够 ...
- Java 常用单词
1.Object-Oriented ['əbdʒekt'ɔ:rɪəntɪd] 面向对象 adj 2.inheritance [ɪnˈherɪtəns] 继承;遗传;遗产 n inherit [ɪ ...
- spring Boot+spring Cloud实现微服务详细教程第一篇
前些天项目组的大佬跟我聊,说项目组想从之前的架构上剥离出来公用的模块做微服务的开发,恰好去年的5/6月份在上家公司学习了国内开源的dubbo+zookeeper实现的微服务的架构.自己平时对微服务的设 ...
- java 单向链表实现
1 class Node{//Node类 2 private String data; 3 private Node next; 4 public Node(String data){ 5 this. ...
- Oracle查询优化改写--------------------给查询结果排序
一.查看员工所雇员工信息(查询部门号==10并且按照入职时间升序排序.第二种用数字来代替) 二.按多个字段排序(dmpno,deptno,sal,ename,job) 三.按照子串排序(有一种速查方法 ...