我对构建web应用程序是新手。我正在尝试使用springboot和mysql数据库构建简单的web应用程序。我在mysql workbench中创建了早期的数据库,但我不断得到这些异常:java.sql.sqlnontransientconnectionexception:无法创建到数据库服务器的连接。尝试重新连接3次。放弃。原因:com.mysql.cj.exceptions.cjexception:拒绝访问用户“”@'localhost'(使用密码:否)
我的application.properties文件:
spring.datasource.url=jdbc:mysql://localhost:3306/appautoreconnect=true&usessl=false
spring.datasource.data username=myusername
spring.datasource.data password=mypassword
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.mysql5innodbdialect
spring.jpa.hibernate.ddl auto=更新
logging.level.org.hibernate.sql=调试
logging.level.org.hibernate.type=跟踪
我的pom.xml依赖项:
<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>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
谢谢你的帮助
1条答案
按热度按时间9njqaruj1#
不管怎样,我在appapplication.properties中更改了:
spring.datasource.data.username=root spring.datasource.data.password=root
至
spring.datasource.username=root spring.datasource.password=root
现在它起作用了。