一、概念和由来

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 概念和起步的更多相关文章

  1. SpringBoot基础学习(一) SpringBoot概念、简单案例实现、单元测试及热部署讲解

    SpringBoot概念 Spring优缺点分析 Spring优点 Spring是Java企业版(Java Enterprise Edition,JEE,也称J2EE)的轻量级代替品,无需开发重量级的 ...

  2. SpringBoot系列教程起步

    本篇学习目标 Spring Boot是什么? 构建Spring Boot应用程序 三分钟开发SpringBoot应用程序 本章源码下载 Spring Boot是什么? spring Boot是由Piv ...

  3. 关于springboot

    概念 Spring的优缺点 1. 优点(AOP和IOC简化开发) Spring是Java企业版(Java Enterprise Edition,JEE,也称J2EE)的轻量级代替品.无需开发重量级的E ...

  4. Java工程师之SpringBoot系列教程前言&目录

    前言 与时俱进是每一个程序员都应该有的意识,当一个Java程序员在当代步遍布的时候,你就行该想到我能多学点什么.可观的是后端的框架是稳定的,它们能够维持更久的时间在应用中,而不用担心技术的更新换代.但 ...

  5. SpringBoot的基础

    概念 Spring的优缺点 1. 优点(AOP和IOC简化开发) Spring是Java企业版(Java Enterprise Edition,JEE,也称J2EE)的轻量级代替品.无需开发重量级的E ...

  6. SpringBoot教程——检视阅读

    SpringBoot教程--检视阅读 参考 SpringBoot教程--一点--蓝本--springboot2.1.1 SpringBoot教程--易百--springboo2.0.5.RELEASE ...

  7. SpringBoot和微服务

    SpringCloud SpringBoot 概念 应用 微服务CAP Consistency(数据强一致性),Availability(服务可用性),Partition-tolerance(分区容错 ...

  8. springboot依赖

    springboot依赖整合 <parent> <groupId>org.springframework.boot</groupId> <artifactId ...

  9. JPA、Hibernate、Spring data jpa之间的关系,以及和springboot的整合

    什么么是JPA? 全称Java Persistence API,可以通过注解或者XML描述[对象-关系表]之间的映射关系,并将实体对象持久化到数据库中. 为我们提供了: 1)ORM映射元数据:JPA支 ...

随机推荐

  1. 原生jdbc操作mysql数据库详解

    首先给大家说一下使用JDBC链接数据库的步骤 1.加载链接数据库驱动 2.建立数据库链接 3.创建数据库操作对象 4.编写sql语句,执行sql语句 5.获取结果集 6.释放资源 我这边采用的是mav ...

  2. 设计模式——建造者模式/生成器模式(C++实现)

    #include <iostream> #include <string> using namespace std; class STProduct { public: voi ...

  3. Maven-04: 三套生命周期

    Maven的生命周期不是一个整体,而是拥有三套相互独立的生命周期,它们分别是clean,default和site. clean生命周期的目的是清理项目. default生命周期的目的是构建项目. si ...

  4. Maven-03: 优化依赖

    已解析依赖: Maven会自动解析项目的直接依赖和传递性依赖,并且根据规则正确判断每个依赖的范围,对于一些依赖冲突,也能进行调节,以确保任何一个构件只有唯一的版本在依赖中存在.在这些工作之后,最后得到 ...

  5. react开发

    webpack.config.js var webpack=require("webpack"); var htmlWebpackPlugin=require('html-webp ...

  6. Access第一周总结

    数据库[DataBase]是存放数据的仓库,是长期存在计算机的,有组织的.大量的.可共享的数据集合:数据模型的概念有:实体[Entity].属性[Attribute].关键字[Key].域[Domai ...

  7. Lombok介绍、使用方法和总结

    1 Lombok背景介绍 官方介绍如下: Project Lombok makes java a spicier language by adding 'handlers' that know how ...

  8. spring boot jsp页面

    相关内容访问: http://www.cnblogs.com/zj0208/p/5985698.html

  9. 实现Windows程序的数据绑定

    1.创建DataSet对象 语法: DataSet  数据集对象  =new  DataSet("数据集的名称字符串"); 语法中的参数是数据集的名称字符串,可以有,也可以没有.如 ...

  10. 路径字符串数据转化为树型层级对象,path to json tree

    由于项目中使用了react 及 ant-design ,在使用tree树型控件时,需要 类似下面的数据, const treeData = [{ title: '0-0', key: '0-0', c ...