Why spring-boot does not connect to the local mysql server?

I can not connect to my local mysql database. This is my project structure:

enter image description here

This is an error log.

enter image description here

It is strange that he says: "Access is denied for user" @ "localhost" (using password: NO) ", but in my .properties application I have a connection written:

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

My build.gradle file:

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')
}

I'm new to Springboot, but I can connect to my local database when I write a normal Java connection, so why can't Springboot?

+4
source share
1 answer

I suspect this is due to these properties:

spring.datasource.data-username=root
spring.datasource.data-password=stepin

spring.datasource.username=root
spring.datasource.password=stepin

DDL DML. .

https://github.com/spring-projects/spring-boot/blob/master/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc:

spring.datasource.data= # Data (DML) script resource reference.
spring.datasource.data-username= # User of the database to execute DML scripts (if different).
spring.datasource.data-password= # Password of the database to execute DML scripts (if different).
spring.datasource.username=
spring.datasource.password= # Login password of the database.
+3

Source: https://habr.com/ru/post/1658088/


All Articles