我收到此错误:“引起: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
答案 0 :(得分:0)
请查看以下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-jersey</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-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
答案 1 :(得分:0)
没有必要提及&#34;司机&#34;在你的application.properties中,它出现了两次应该注入的驱动程序的冲突。你在pom.xml中再次提到它。在application.properties中提到一次DriverClassName就足够了。