When using mysql in the springboot project, we need to config the application.properties to enable it.
first, config the application.properties
application.properties
# application.properties
spring.datasource.url=jdbc:mysql://localhost:3306/test
spring.datasource.username=root
spring.datasource.password=wsn++123
spring.datasource.driverClassName=com.mysql.jdbc.Driver# Specify the DBMS
spring.jpa.database = MYSQL
# Show or not log for each sql query
spring.jpa.show-sql = true
# Hibernate settings are prefixed with spring.jpa.hibernate.*
spring.jpa.hibernate.ddl-auto = update
spring.jpa.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect
spring.jpa.hibernate.naming_strategy = org.hibernate.cfg.ImprovedNamingStrategy
second config the compile dependencies in build.gradle
build.gradle
buildscript {
repositories {
maven {
url "http://repo.maven.apache.org/maven2/"
}
mavenCentral()
}
dependencies {
classpath group: 'co.tomlee.gradle.plugins', name: 'gradle-thrift-plugin', version: '0.0.6'
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.1.10.RELEASE")
}
}
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'thrift'
apply plugin: 'spring-boot'
apply plugin: 'war'
sourceCompatibility = 1.7version = '1.0'
repositories {
mavenCentral()
}
dependencies {
compile 'org.apache.thrift:libthrift:0.9.2'
compile 'org.springframework:spring-orm:4.1.4.RELEASE'
compile('org.springframework.boot:spring-boot-starter-web:1.2.1.RELEASE')
compile('org.springframework.boot:spring-boot-starter-data-jpa:1.2.2.RELEASE')
//compile('org.springframework.boot:spring-boot-starter-actuator:1.2.2.RELEASE')
compile('org.springframework:spring-jdbc:4.1.5.RELEASE')
//compile('com.h2database:h2:1.4.185') // mysql
compile('mysql:mysql-connector-java:5.1.34')
// hibernate
compile('org.hibernate:hibernate-entitymanager:4.3.8.Final')
compile('org.projectreactor.spring:reactor-spring-context:1.1.3.RELEASE')
compile('org.springframework:spring-web:4.1.5.RELEASE')
compile('org.springframework.amqp:spring-rabbit:1.4.2.RELEASE')
compile('org.springframework.amqp:spring-amqp:1.4.2.RELEASE')
compile group: 'org.springframework.data', name: 'spring-data-mongodb', version: '1.6.1.RELEASE'
compile "org.springframework.data:spring-data-rest-webmvc:2.2.1.RELEASE"
compile("com.fasterxml.jackson.core:jackson-databind:2.5.0")
compile("com.fasterxml.jackson.core:jackson-annotations:2.5.0")
compile("com.fasterxml.jackson.core:jackson-core:2.5.0")
//compile group: 'org.hibernate', name: 'hibernate-core', version: '4.3.7.Final'
compile('org.springframework:spring-test:4.1.5.RELEASE')
testCompile group: 'junit', name: 'junit', version: '4.11'
}
generateThriftSource {
// // The output directory (optional) //
out file('src/main/thrift-java')
verbose false
debug false
strict true // // Modify the include path (optional) // // path file('vendor/thrift') // // Set the thrift executable (optional) //
executable 'C:\\Program Files (x86)\\Java\\jdk1.7.0_40\\bin\\thrift.exe'
generators {
// // --gen java:hashcode,beans //
java {
// // Options passed to the `java` generator //
option 'hashcode'
option 'beans'
}
}
}
sourceSets {
main {
java {
srcDirs = ['src/main/java', 'src/main/thrift-java', 'src/main/wsdc-api']
}
resources {
srcDirs = ['src/main/resources']
}
}
test {
java {
srcDirs = ['src/test/java', 'src/test/thrift']
}
resources {
srcDirs = ['src/test/resources']
}
}
}
jar {
// set the main class entry for the executable jar
manifest {
attributes 'Main-Class': 'calculator.CalculatorClient',
'Implementation-Title': 'Gradle quickStart'
}
// this will add all the dependent jars into the generated-jar packagefrom {
configurations.compile.collect {
it.isDirectory() ? it : zipTree(it)
}
}
}