0
点赞
收藏
分享

微信扫一扫

【SpringBoot】启动SpringBoot并且配置数据库连接


目录

​​一、版本介绍​​

         ​​二、gradle配置​​

         ​​三、properties配置​​

​​四、启动项目 ​​

一、版本介绍

1. SpringBoot版本2.4.8
2. Gradel版本6.8.3

3. MySQL版本5.7

二、gradle配置

plugins {
id 'org.springframework.boot' version '2.4.8'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'java'
}

group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'

configurations {
compileOnly {
extendsFrom annotationProcessor
}
}

repositories {
maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
maven { url 'http://maven.aliyun.com/nexus/content/repositories/jcenter' }
mavenCentral()
}

dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-data-redis'
implementation 'org.springframework.boot:spring-boot-starter-jdbc'
implementation 'org.springframework.kafka:spring-kafka'
compileOnly 'org.projectlombok:lombok'
runtimeOnly 'io.micrometer:micrometer-registry-prometheus'
runtimeOnly 'mysql:mysql-connector-java'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.kafka:spring-kafka-test'
}

test {
useJUnitPlatform()
}

三、properties配置

server.port=8080

# springboot启动出现Access to DialectResolutionInfo cannot be null when ‘hibernate.dialect‘ not set,加上这个
spring.jpa.database-platform=org.hibernate.dialect.MySQLDialect

spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/demo?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&useSSL=false
spring.datasource.username=root
spring.datasource.password=

四、启动项目 

【SpringBoot】启动SpringBoot并且配置数据库连接_数据库

五、参考资料

​​springboot启动出现Access to DialectResolutionInfo cannot be null when ‘hibernate.dialect‘ not set​​

举报

相关推荐

0 条评论