SpringBoot 概念和起步

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、前端代碼

SpringBoot 概念和起步

SpringBoot 概念和起步

SpringBoot 概念和起步

4、啟動應用

在IDE中直接直接執行main方法,然後訪問http://localhost:8080即可。

三、附錄

1、thymeleaf Exception parsing document: template="xxxx"錯誤

Thymeleaf模板引擎,遇到不閉合標籤會報這個錯誤,很是蛋疼啊。最後發現是自動生成的meta標籤沒有關閉,太太坑了。

SpringBoot 概念和起步

網上搜來的解決方案:

(1). 添加maven依賴

net.sourceforge.nekohtml

nekohtml

1.9.22

(2). 更改application.properties屬性

spring.thymeleaf.mode=LEGACYHTML5


分享到:


相關文章: