我收到此错误:“由以下原因引起:java.lang.IllegalStateException:无法加载驱动程序类:com.mysql.jdbc.Driver”
这是 POM 部分:
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
这是我的应用程序属性:
spring.datasource.url = jdbc:mysql://localhost
spring.datasource.driverClassName = com.mysql.jdbc.Driver
spring.datasource.name=demodb
spring.datasource.username=root@localhost
spring.datasource.password=1234
spring.datasource.driver-class-name= com.mysql.jdbc.Driver
spring.jpa.database=mysql
spring.jpa.database-platform=org.hibernate.dialect.MySQLDialect
这是完整的堆栈跟踪:
https://gist.github.com/vt97john/f21c7a181fb7e4935a817e7aa84e20d1
最佳答案
无需在 application.properties 中两次提及“Drivers”,否则会产生应注入(inject)哪个 Driver 的冲突。您在 pom.xml 中再次提到了它。在 application.properties 中提及一次 DriverClassName 就足够了。
关于mysql - 我怎样才能让我的 Spring Boot 应用程序找到我的 mysql jdbc jar?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43506197/