Spring boot with error connecting to mysql

1

I created a test project by Spring Tool Suite to create a REST server that will connect to a local mysql database, when I start the app in error when trying to connect to mysql: java.sql .SQLException: Access denied for user '' @ 'localhost' (using password: NO)

I find it strange that it did not try with the root user I set up in the project.

The application.properties looks like this:

spring.jpa.show-sql=true
spring.jpa.database=mysql

spring.datasource.url=jdbc:mysql://localhost/users
spring.datasource.data-username=root
spring.datasource.data-password=12345
spring.datasource.driver-class-name=com.mysql.jdbc.Driver

And the pom.xml looks like this:

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <java.version>1.8</java.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <scope>runtime</scope>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>

In the database I ran the following command:

GRANT ALL ON *.* TO 'root'@'%' IDENTIFIED BY '12345';

After running I stopped and started mysql.

I understand this command to access root in all tables and from anywhere.

I find it strange that in the error '' @ localhost '' appears instead of 'root' @ 'localhost', it does not seem to get the configuration to access the database.

It will be config. of the connection that is wrong, the pom.xml or the bank?

    
asked by anonymous 12.10.2016 / 20:26

1 answer

1

Can you send the directory tree you are using? How are you doing to perform? The "(using password: NO)" error means that Spring Boot was unable to reflect the settings in your Properties file.

Make sure the directory of the Properties file is /project/src/main/resources/application.properties

In addition their properties are not correct. Use: spring.datasource.username = root spring.datasource.password = 12345

Example: link

: D

    
12.10.2016 / 20:52