我知道这个问题之前被问了1000次,找不到解决方案似乎对我有用。 我正在尝试构建一个简单的webapp,但是当我尝试实现jpa来保存用户并让用户登录时,任何东西都无法工作。 应用程序首先启动正常,但访问localhost:8080时,我的jsp没有显示。 一段时间后,应用程序崩溃了。 堆栈可以追溯到:
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:
Access denied for user 'ufotje'@'%' to database 'hbo5_java'
我知道提供的凭据是正确的(我可以通过datagrip连接到数据库......)。
我认为我的application.propperties有些错误,但无法弄清楚是什么。
我的application.propperties:
spring.mvc.view.prefix=/WEB-INF/jsp/
spring.mvc.view.suffix=.jsp
spring.mvc.date-format=dd/mm/yyyy
spring.data.jpa.repositories.enabled=true
spring.datasource.url=jdbc:mysql://85.10.205.173
/hbo5_java?verifyServerCertificate=false&useSSL=true
spring.datasource.username=ufotje
spring.datasource.password=bd5296
spring.datasource.driverClassName=com.mysql.jdbc.Driver
spring.datasource.testWhileIdle=true
spring.jpa.generate-ddl=true
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=update
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
spring.jpa.hibernate.naming.strategy=org.hibernate.cfg.EJB3NamingStrategy
我的pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>be.intec</groupId>
<artifactId>pictureThisPictureThat</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>Picture This, Picture That</name>
<description></description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.6.RELEASE</version>
<relativePath/>
</parent>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<executable>true</executable>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>
UTF8
</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>required</scope>
</dependency>
<dependency>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat8-maven-plugin</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>Mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
答案 0 :(得分:0)
检查是否允许用户进行远程连接,在数据库下面运行SQL查询以允许用户从任何地方进行连接。
允许用户从任何地方进行连接
GRANT ALL ON *.* to <user-name>@'<ip>' IDENTIFIED BY '<password>'
示例: -
GRANT ALL ON *.* to ufotje@'%' IDENTIFIED BY 'bd5296';
//授予root用户从任何地方连接(%),它具有root密码。