java为什么要连接Mysql_java – 为什么spring-boot连接到本地mysql服务器?

无法将springboot连接到我的localhost mysql数据库.

这是我的项目结构:

e17b9e056b7ff9aabd2c966d6f5d6ecc.png

这是错误日志.

03eb6812b8aab1216fa2b1131219f8f1.png

奇怪的是他说:“访问被拒绝用户”’localhost'(使用密码:NO)”,但是在我的application.properties中我写了连接:

server.port=8080

spring.main.banner-mode=off

spring.thymeleaf.cache=false

spring.freemarker.cache=false

spring.groovy.template.cache=false

spring.datasource.url=jdbc:MysqL://localhost:3306/user?autoReconnect=true&useSSL=false

spring.datasource.data-username=root

spring.datasource.data-password=stepin

spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MysqL5Dialect

spring.jpa.hibernate.ddl-auto=update

spring.jpa.show-sql=true

我的build.gradle文件:

buildscript {

ext {

springBootVersion = '1.4.1.RELEASE'

}

repositories {

mavenCentral()

}

dependencies {

classpath("org.springframework.boot:spring-boot-gradle- plugin:${springBootVersion}")

}

}

apply plugin: 'java'

apply plugin: 'eclipse'

apply plugin: 'spring-boot'

jar {

baseName = 'databaseaccess'

version = '0.0.1-SNAPSHOT'

}

sourceCompatibility = 1.8

targetCompatibility = 1.8

repositories {

mavenCentral()

}

dependencies {

compile('org.springframework.boot:spring-boot-starter-data-jpa')

compile('org.springframework.boot:spring-boot-starter-web')

compile('MysqL:MysqL-connector-java')

runtime("com.h2database:h2")

testCompile('org.springframework.boot:spring-boot-starter-test')

}

我是springboot的新手,但我可以连接到我的本地数据库,当我写正常的java连接时,为什么springboot不能?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值