SpringBoot uses mysql as the database

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.7

version = '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 package
    from {
        configurations.compile.collect {
            it.isDirectory() ? it : zipTree(it)
        }
    }
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值