Cannot load driver class: com.mysql.cj.jdbc.Driver
Posted tfy1332
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Cannot load driver class: com.mysql.cj.jdbc.Driver相关的知识,希望对你有一定的参考价值。
"C:\\Program Files\\Java\\jdk1.8.0_181\\bin\\java.exe" -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:61441,suspend=y,server=n -XX:TieredStopAtLevel=1 -noverify -Dspring.output.ansi.enabled=always -Dcom.sun.management.jmxremote -Dspring.jmx.enabled=true -Dspring.liveBeansView.mbeanDomain -Dspring.application.admin.enabled=true "-Dmanagement.endpoints.jmx.exposure.include=*" -javaagent:C:\\Users\\Lucas\\AppData\\Local\\JetBrains\\IntelliJIdea2022.3\\captureAgent\\debugger-agent.jar -Dfile.encoding=UTF-8 -classpath "C:\\Program Files\\Java\\jdk1.8.0_181\\jre\\lib\\charsets.jar;C:\\Program Files\\Java\\jdk1.8.0_181\\jre\\lib\\deploy.jar;C:\\Program Files\\Java\\jdk1.8.0_181\\jre\\lib\\ext\\access-bridge-64.jar;C:\\Program Files\\Java\\jdk1.8.0_181\\jre\\lib\\ext\\cldrdata.jar;C:\\Program Files\\Java\\jdk1.8.0_181\\jre\\lib\\ext\\dnsns.jar;C:\\Program Files\\Java\\jdk1.8.0_181\\jre\\lib\\ext\\jaccess.jar;C:\\Program Files\\Java\\jdk1.8.0_181\\jre\\lib\\ext\\jfxrt.jar;C:\\Program Files\\Java\\jdk1.8.0_181\\jre\\lib\\ext\\localedata.jar;C:\\Program Files\\Java\\jdk1.8.0_181\\jre\\lib\\ext\\nashorn.jar;C:\\Program Files\\Java\\jdk1.8.0_181\\jre\\lib\\ext\\sunec.jar;C:\\Program Files\\Java\\jdk1.8.0_181\\jre\\lib\\ext\\sunjce_provider.jar;C:\\Program Files\\Java\\jdk1.8.0_181\\jre\\lib\\ext\\sunmscapi.jar;C:\\Program Files\\Java\\jdk1.8.0_181\\jre\\lib\\ext\\sunpkcs11.jar;C:\\Program Files\\Java\\jdk1.8.0_181\\jre\\lib\\ext\\zipfs.jar;C:\\Program Files\\Java\\jdk1.8.0_181\\jre\\lib\\javaws.jar;C:\\Program Files\\Java\\jdk1.8.0_181\\jre\\lib\\jce.jar;C:\\Program Files\\Java\\jdk1.8.0_181\\jre\\lib\\jfr.jar;C:\\Program Files\\Java\\jdk1.8.0_181\\jre\\lib\\jfxswt.jar;C:\\Program Files\\Java\\jdk1.8.0_181\\jre\\lib\\jsse.jar;C:\\Program Files\\Java\\jdk1.8.0_181\\jre\\lib\\management-agent.jar;C:\\Program Files\\Java\\jdk1.8.0_181\\jre\\lib\\plugin.jar;C:\\Program Files\\Java\\jdk1.8.0_181\\jre\\lib\\resources.jar;C:\\Program Files\\Java\\jdk1.8.0_181\\jre\\lib\\rt.jar;C:\\tfy\\code\\springbootDemo\\springbootDemo\\target\\classes;C:\\Users\\Lucas\\.m2\\repository\\org\\springframework\\boot\\spring-boot-starter-data-jdbc\\2.6.11\\spring-boot-starter-data-jdbc-2.6.11.jar;C:\\Users\\Lucas\\.m2\\repository\\org\\springframework\\data\\spring-data-jdbc\\2.3.6\\spring-data-jdbc-2.3.6.jar;C:\\Users\\Lucas\\.m2\\repository\\org\\springframework\\data\\spring-data-relational\\2.3.6\\spring-data-relational-2.3.6.jar;C:\\Users\\Lucas\\.m2\\repository\\org\\springframework\\data\\spring-data-commons\\2.6.6\\spring-data-commons-2.6.6.jar;C:\\Users\\Lucas\\.m2\\repository\\org\\springframework\\spring-tx\\5.3.22\\spring-tx-5.3.22.jar;C:\\Users\\Lucas\\.m2\\repository\\org\\springframework\\spring-context\\5.3.22\\spring-context-5.3.22.jar;C:\\Users\\Lucas\\.m2\\repository\\org\\springframework\\spring-beans\\5.3.22\\spring-beans-5.3.22.jar;C:\\Users\\Lucas\\.m2\\repository\\org\\slf4j\\slf4j-api\\1.7.36\\slf4j-api-1.7.36.jar;C:\\Users\\Lucas\\.m2\\repository\\org\\springframework\\boot\\spring-boot-starter-data-jpa\\2.6.11\\spring-boot-starter-data-jpa-2.6.11.jar;C:\\Users\\Lucas\\.m2\\repository\\org\\springframework\\boot\\spring-boot-starter-aop\\2.6.11\\spring-boot-starter-aop-2.6.11.jar;C:\\Users\\Lucas\\.m2\\repository\\org\\springframework\\spring-aop\\5.3.22\\spring-aop-5.3.22.jar;C:\\Users\\Lucas\\.m2\\repository\\org\\aspectj\\aspectjweaver\\1.9.7\\aspectjweaver-1.9.7.jar;C:\\Users\\Lucas\\.m2\\repository\\jakarta\\transaction\\jakarta.transaction-api\\1.3.3\\jakarta.transaction-api-1.3.3.jar;C:\\Users\\Lucas\\.m2\\repository\\jakarta\\persistence\\jakarta.persistence-api\\2.2.3\\jakarta.persistence-api-2.2.3.jar;C:\\Users\\Lucas\\.m2\\repository\\org\\hibernate\\hibernate-core\\5.6.10.Final\\hibernate-core-5.6.10.Final.jar;C:\\Users\\Lucas\\.m2\\repository\\org\\jboss\\logging\\jboss-logging\\3.4.3.Final\\jboss-logging-3.4.3.Final.jar;C:\\Users\\Lucas\\.m2\\repository\\net\\bytebuddy\\byte-buddy\\1.11.22\\byte-buddy-1.11.22.jar;C:\\Users\\Lucas\\.m2\\repository\\antlr\\antlr\\2.7.7\\antlr-2.7.7.jar;C:\\Users\\Lucas\\.m2\\repository\\org\\jboss\\jandex\\2.4.2.Final\\jandex-2.4.2.Final.jar;C:\\Users\\Lucas\\.m2\\repository\\com\\fasterxml\\classmate\\1.5.1\\classmate-1.5.1.jar;C:\\Users\\Lucas\\.m2\\repository\\org\\hibernate\\common\\hibernate-commons-annotations\\5.1.2.Final\\hibernate-commons-annotations-5.1.2.Final.jar;C:\\Users\\Lucas\\.m2\\repository\\org\\glassfish\\jaxb\\jaxb-runtime\\2.3.6\\jaxb-runtime-2.3.6.jar;C:\\Users\\Lucas\\.m2\\repository\\org\\glassfish\\jaxb\\txw2\\2.3.6\\txw2-2.3.6.jar;C:\\Users\\Lucas\\.m2\\repository\\com\\sun\\istack\\istack-commons-runtime\\3.0.12\\istack-commons-runtime-3.0.12.jar;C:\\Users\\Lucas\\.m2\\repository\\com\\sun\\activation\\jakarta.activation\\1.2.2\\jakarta.activation-1.2.2.jar;C:\\Users\\Lucas\\.m2\\repository\\org\\springframework\\data\\spring-data-jpa\\2.6.6\\spring-data-jpa-2.6.6.jar;C:\\Users\\Lucas\\.m2\\repository\\org\\springframework\\spring-orm\\5.3.22\\spring-orm-5.3.22.jar;C:\\Users\\Lucas\\.m2\\repository\\org\\springframework\\spring-aspects\\5.3.22\\spring-aspects-5.3.22.jar;C:\\Users\\Lucas\\.m2\\repository\\org\\springframework\\boot\\spring-boot-starter-jdbc\\2.6.11\\spring-boot-starter-jdbc-2.6.11.jar;C:\\Users\\Lucas\\.m2\\repository\\org\\springframework\\boot\\spring-boot-starter\\2.6.11\\spring-boot-starter-2.6.11.jar;C:\\Users\\Lucas\\.m2\\repository\\org\\springframework\\boot\\spring-boot\\2.6.11\\spring-boot-2.6.11.jar;C:\\Users\\Lucas\\.m2\\repository\\org\\springframework\\boot\\spring-boot-autoconfigure\\2.6.11\\spring-boot-autoconfigure-2.6.11.jar;C:\\Users\\Lucas\\.m2\\repository\\org\\springframework\\boot\\spring-boot-starter-logging\\2.6.11\\spring-boot-starter-logging-2.6.11.jar;C:\\Users\\Lucas\\.m2\\repository\\ch\\qos\\logback\\logback-classic\\1.2.11\\logback-classic-1.2.11.jar;C:\\Users\\Lucas\\.m2\\repository\\ch\\qos\\logback\\logback-core\\1.2.11\\logback-core-1.2.11.jar;C:\\Users\\Lucas\\.m2\\repository\\org\\apache\\logging\\log4j\\log4j-to-slf4j\\2.17.2\\log4j-to-slf4j-2.17.2.jar;C:\\Users\\Lucas\\.m2\\repository\\org\\apache\\logging\\log4j\\log4j-api\\2.17.2\\log4j-api-2.17.2.jar;C:\\Users\\Lucas\\.m2\\repository\\org\\slf4j\\jul-to-slf4j\\1.7.36\\jul-to-slf4j-1.7.36.jar;C:\\Users\\Lucas\\.m2\\repository\\jakarta\\annotation\\jakarta.annotation-api\\1.3.5\\jakarta.annotation-api-1.3.5.jar;C:\\Users\\Lucas\\.m2\\repository\\org\\yaml\\snakeyaml\\1.29\\snakeyaml-1.29.jar;C:\\Users\\Lucas\\.m2\\repository\\com\\zaxxer\\HikariCP\\4.0.3\\HikariCP-4.0.3.jar;C:\\Users\\Lucas\\.m2\\repository\\org\\springframework\\spring-jdbc\\5.3.22\\spring-jdbc-5.3.22.jar;C:\\Users\\Lucas\\.m2\\repository\\org\\springframework\\boot\\spring-boot-starter-thymeleaf\\2.6.11\\spring-boot-starter-thymeleaf-2.6.11.jar;C:\\Users\\Lucas\\.m2\\repository\\org\\thymeleaf\\thymeleaf-spring5\\3.0.15.RELEASE\\thymeleaf-spring5-3.0.15.RELEASE.jar;C:\\Users\\Lucas\\.m2\\repository\\org\\thymeleaf\\thymeleaf\\3.0.15.RELEASE\\thymeleaf-3.0.15.RELEASE.jar;C:\\Users\\Lucas\\.m2\\repository\\org\\attoparser\\attoparser\\2.0.5.RELEASE\\attoparser-2.0.5.RELEASE.jar;C:\\Users\\Lucas\\.m2\\repository\\org\\unbescape\\unbescape\\1.1.6.RELEASE\\unbescape-1.1.6.RELEASE.jar;C:\\Users\\Lucas\\.m2\\repository\\org\\thymeleaf\\extras\\thymeleaf-extras-java8time\\3.0.4.RELEASE\\thymeleaf-extras-java8time-3.0.4.RELEASE.jar;C:\\Users\\Lucas\\.m2\\repository\\org\\springframework\\boot\\spring-boot-starter-web\\2.6.11\\spring-boot-starter-web-2.6.11.jar;C:\\Users\\Lucas\\.m2\\repository\\org\\springframework\\boot\\spring-boot-starter-json\\2.6.11\\spring-boot-starter-json-2.6.11.jar;C:\\Users\\Lucas\\.m2\\repository\\com\\fasterxml\\jackson\\core\\jackson-databind\\2.13.3\\jackson-databind-2.13.3.jar;C:\\Users\\Lucas\\.m2\\repository\\com\\fasterxml\\jackson\\core\\jackson-annotations\\2.13.3\\jackson-annotations-2.13.3.jar;C:\\Users\\Lucas\\.m2\\repository\\com\\fasterxml\\jackson\\core\\jackson-core\\2.13.3\\jackson-core-2.13.3.jar;C:\\Users\\Lucas\\.m2\\repository\\com\\fasterxml\\jackson\\datatype\\jackson-datatype-jdk8\\2.13.3\\jackson-datatype-jdk8-2.13.3.jar;C:\\Users\\Lucas\\.m2\\repository\\com\\fasterxml\\jackson\\datatype\\jackson-datatype-jsr310\\2.13.3\\jackson-datatype-jsr310-2.13.3.jar;C:\\Users\\Lucas\\.m2\\repository\\com\\fasterxml\\jackson\\module\\jackson-module-parameter-names\\2.13.3\\jackson-module-parameter-names-2.13.3.jar;C:\\Users\\Lucas\\.m2\\repository\\org\\springframework\\boot\\spring-boot-starter-tomcat\\2.6.11\\spring-boot-starter-tomcat-2.6.11.jar;C:\\Users\\Lucas\\.m2\\repository\\org\\apache\\tomcat\\embed\\tomcat-embed-core\\9.0.65\\tomcat-embed-core-9.0.65.jar;C:\\Users\\Lucas\\.m2\\repository\\org\\apache\\tomcat\\embed\\tomcat-embed-el\\9.0.65\\tomcat-embed-el-9.0.65.jar;C:\\Users\\Lucas\\.m2\\repository\\org\\apache\\tomcat\\embed\\tomcat-embed-websocket\\9.0.65\\tomcat-embed-websocket-9.0.65.jar;C:\\Users\\Lucas\\.m2\\repository\\org\\springframework\\spring-web\\5.3.22\\spring-web-5.3.22.jar;C:\\Users\\Lucas\\.m2\\repository\\org\\springframework\\spring-webmvc\\5.3.22\\spring-webmvc-5.3.22.jar;C:\\Users\\Lucas\\.m2\\repository\\org\\springframework\\spring-expression\\5.3.22\\spring-expression-5.3.22.jar;C:\\Users\\Lucas\\.m2\\repository\\org\\postgresql\\postgresql\\42.3.6\\postgresql-42.3.6.jar;C:\\Users\\Lucas\\.m2\\repository\\org\\checkerframework\\checker-qual\\3.5.0\\checker-qual-3.5.0.jar;C:\\Users\\Lucas\\.m2\\repository\\jakarta\\xml\\bind\\jakarta.xml.bind-api\\2.3.3\\jakarta.xml.bind-api-2.3.3.jar;C:\\Users\\Lucas\\.m2\\repository\\jakarta\\activation\\jakarta.activation-api\\1.2.2\\jakarta.activation-api-1.2.2.jar;C:\\Users\\Lucas\\.m2\\repository\\org\\springframework\\spring-core\\5.3.22\\spring-core-5.3.22.jar;C:\\Users\\Lucas\\.m2\\repository\\org\\springframework\\spring-jcl\\5.3.22\\spring-jcl-5.3.22.jar;C:\\Program Files\\JetBrains\\IntelliJ IDEA 2022.3.1\\lib\\idea_rt.jar" com.example.springbootdemo.SpringbootDemoApplication
Connected to the target VM, address: '127.0.0.1:61441', transport: 'socket'
. ____ _ __ _ _
/\\\\ / ___'_ __ _ _(_)_ __ __ _ \\ \\ \\ \\
( ( )\\___ | '_ | '_| | '_ \\/ _` | \\ \\ \\ \\
\\\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.6.11)
2023-01-11 08:57:00.918 INFO 91072 --- [ main] c.e.s.SpringbootDemoApplication : Starting SpringbootDemoApplication using Java 1.8.0_181 on DESKTOP-JSP3CM3 with PID 91072 (C:\\tfy\\code\\springbootDemo\\springbootDemo\\target\\classes started by Lucas in C:\\tfy\\code\\springbootDemo\\springbootDemo)
2023-01-11 08:57:00.921 INFO 91072 --- [ main] c.e.s.SpringbootDemoApplication : No active profile set, falling back to 1 default profile: "default"
2023-01-11 08:57:01.616 INFO 91072 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configuration mode
2023-01-11 08:57:01.617 INFO 91072 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JDBC repositories in DEFAULT mode.
2023-01-11 08:57:01.628 INFO 91072 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 5 ms. Found 0 JDBC repository interfaces.
2023-01-11 08:57:01.639 INFO 91072 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configuration mode
2023-01-11 08:57:01.639 INFO 91072 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2023-01-11 08:57:01.649 INFO 91072 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 2 ms. Found 0 JPA repository interfaces.
2023-01-11 08:57:02.220 INFO 91072 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2023-01-11 08:57:02.228 INFO 91072 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2023-01-11 08:57:02.228 INFO 91072 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.65]
2023-01-11 08:57:02.398 INFO 91072 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2023-01-11 08:57:02.398 INFO 91072 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1432 ms
2023-01-11 08:57:02.464 WARN 91072 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'dataSourceScriptDatabaseInitializer' defined in class path resource [org/springframework/boot/autoconfigure/sql/init/DataSourceInitializationConfiguration.class]: Unsatisfied dependency expressed through method 'dataSourceScriptDatabaseInitializer' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception; nested exception is java.lang.IllegalStateException: Cannot load driver class: com.mysql.cj.jdbc.Driver
2023-01-11 08:57:02.466 INFO 91072 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2023-01-11 08:57:02.488 INFO 91072 --- [ main] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2023-01-11 08:57:02.511 ERROR 91072 --- [ main] o.s.boot.SpringApplication : Application run failed
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'dataSourceScriptDatabaseInitializer' defined in class path resource [org/springframework/boot/autoconfigure/sql/init/DataSourceInitializationConfiguration.class]: Unsatisfied dependency expressed through method 'dataSourceScriptDatabaseInitializer' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception; nested exception is java.lang.IllegalStateException: Cannot load driver class: com.mysql.cj.jdbc.Driver
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:800) ~[spring-beans-5.3.22.jar:5.3.22]
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:541) ~[spring-beans-5.3.22.jar:5.3.22]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1352) ~[spring-beans-5.3.22.jar:5.3.22]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1195) ~[spring-beans-5.3.22.jar:5.3.22]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582) ~[spring-beans-5.3.22.jar:5.3.22]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.22.jar:5.3.22]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.22.jar:5.3.22]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.22.jar:5.3.22]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.22.jar:5.3.22]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.22.jar:5.3.22]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322) ~[spring-beans-5.3.22.jar:5.3.22]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.22.jar:5.3.22]
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1154) ~[spring-context-5.3.22.jar:5.3.22]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:908) ~[spring-context-5.3.22.jar:5.3.22]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583) ~[spring-context-5.3.22.jar:5.3.22]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145) ~[spring-boot-2.6.11.jar:2.6.11]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:745) [spring-boot-2.6.11.jar:2.6.11]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:420) [spring-boot-2.6.11.jar:2.6.11]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:307) [spring-boot-2.6.11.jar:2.6.11]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1317) [spring-boot-2.6.11.jar:2.6.11]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1306) [spring-boot-2.6.11.jar:2.6.11]
at com.example.springbootdemo.SpringbootDemoApplication.main(SpringbootDemoApplication.java:10) [classes/:na]
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception; nested exception is java.lang.IllegalStateException: Cannot load driver class: com.mysql.cj.jdbc.Driver
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:658) ~[spring-beans-5.3.22.jar:5.3.22]
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:638) ~[spring-beans-5.3.22.jar:5.3.22]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1352) ~[spring-beans-5.3.22.jar:5.3.22]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1195) ~[spring-beans-5.3.22.jar:5.3.22]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582) ~[spring-beans-5.3.22.jar:5.3.22]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.22.jar:5.3.22]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.22.jar:5.3.22]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.22.jar:5.3.22]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.22.jar:5.3.22]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.22.jar:5.3.22]
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276) ~[spring-beans-5.3.22.jar:5.3.22]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1391) ~[spring-beans-5.3.22.jar:5.3.22]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1311) ~[spring-beans-5.3.22.jar:5.3.22]
at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:887) ~[spring-beans-5.3.22.jar:5.3.22]
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:791) ~[spring-beans-5.3.22.jar:5.3.22]
... 21 common frames omitted
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception; nested exception is java.lang.IllegalStateException: Cannot load driver class: com.mysql.cj.jdbc.Driver
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185) ~[spring-beans-5.3.22.jar:5.3.22]
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:653) ~[spring-beans-5.3.22.jar:5.3.22]
... 35 common frames omitted
Caused by: java.lang.IllegalStateException: Cannot load driver class: com.mysql.cj.jdbc.Driver
at org.springframework.util.Assert.state(Assert.java:97) ~[spring-core-5.3.22.jar:5.3.22]
at org.springframework.boot.autoconfigure.jdbc.DataSourceProperties.determineDriverClassName(DataSourceProperties.java:241) ~[spring-boot-autoconfigure-2.6.11.jar:2.6.11]
at org.springframework.boot.autoconfigure.jdbc.DataSourceProperties.initializeDataSourceBuilder(DataSourceProperties.java:193) ~[spring-boot-autoconfigure-2.6.11.jar:2.6.11]
at org.springframework.boot.autoconfigure.jdbc.DataSourceConfiguration.createDataSource(DataSourceConfiguration.java:48) ~[spring-boot-autoconfigure-2.6.11.jar:2.6.11]
at org.springframework.boot.autoconfigure.jdbc.DataSourceConfiguration$Hikari.dataSource(DataSourceConfiguration.java:90) ~[spring-boot-autoconfigure-2.6.11.jar:2.6.11]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_181]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_181]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_181]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_181]
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.3.22.jar:5.3.22]
... 36 common frames omitted
Disconnected from the target VM, address: '127.0.0.1:61441', transport: 'socket'
Process finished with exit code 1
以上是关于Cannot load driver class: com.mysql.cj.jdbc.Driver的主要内容,如果未能解决你的问题,请参考以下文章
org.apache.commons.dbcp.SQLNestedException: Cannot load JDBC driver class
错误:“Cannot load JDBC driver class 'com.mysql.jdbc.Driver”的解决方法
JDBC Request :Cannot load JDBC driver class 'com.mysql.jdbc.Driver'解决办法
Cannot load JDBC driver class 'com.mysql.jdbc.Driver' 怎么解决?
org.apache.commons.dbcp.SQLNestedException: Cannot load JDBC driver class 'com.microsoft.sqlserv
spring+mybatis整合,org.apache.commons.dbcp.SQLNestedException: Cannot load JDBC driver class '${jd