错误详情
今天在编写springboot项目初始文件时出现了以下错误,大家看清楚错误哈,错误出现的情况也不止一种
D:\software\hspjdk8\bin\java.exe -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:D:\software\idea_2022\IntelliJ IDEA 2022.3.2\lib\idea_rt.jar=62544:D:\software\idea_2022\IntelliJ IDEA 2022.3.2\bin" -Dfile.encoding=UTF-8 -classpath "D:\software\hspjdk8\jre\lib\charsets.jar;D:\software\hspjdk8\jre\lib\deploy.jar;D:\software\hspjdk8\jre\lib\ext\access-bridge-64.jar;D:\software\hspjdk8\jre\lib\ext\cldrdata.jar;D:\software\hspjdk8\jre\lib\ext\dnsns.jar;D:\software\hspjdk8\jre\lib\ext\jaccess.jar;D:\software\hspjdk8\jre\lib\ext\jfxrt.jar;D:\software\hspjdk8\jre\lib\ext\localedata.jar;D:\software\hspjdk8\jre\lib\ext\nashorn.jar;D:\software\hspjdk8\jre\lib\ext\sunec.jar;D:\software\hspjdk8\jre\lib\ext\sunjce_provider.jar;D:\software\hspjdk8\jre\lib\ext\sunmscapi.jar;D:\software\hspjdk8\jre\lib\ext\sunpkcs11.jar;D:\software\hspjdk8\jre\lib\ext\zipfs.jar;D:\software\hspjdk8\jre\lib\javaws.jar;D:\software\hspjdk8\jre\lib\jce.jar;D:\software\hspjdk8\jre\lib\jfr.jar;D:\software\hspjdk8\jre\lib\jfxswt.jar;D:\software\hspjdk8\jre\lib\jsse.jar;D:\software\hspjdk8\jre\lib\management-agent.jar;D:\software\hspjdk8\jre\lib\plugin.jar;D:\software\hspjdk8\jre\lib\resources.jar;D:\software\hspjdk8\jre\lib\rt.jar;D:\IDEA\Intelligent elderly care\target\classes;D:\software\apache-maven-3.6.1\mvn_resp\org\springframework\boot\spring-boot-starter-web\2.4.1\spring-boot-starter-web-2.4.1.jar;D:\software\apache-maven-3.6.1\mvn_resp\org\springframework\boot\spring-boot-starter\2.4.1\spring-boot-starter-2.4.1.jar;D:\software\apache-maven-3.6.1\mvn_resp\org\springframework\boot\spring-boot\2.4.1\spring-boot-2.4.1.jar;D:\software\apache-maven-3.6.1\mvn_resp\org\springframework\boot\spring-boot-starter-logging\2.4.1\spring-boot-starter-logging-2.4.1.jar;D:\software\apache-maven-3.6.1\mvn_resp\ch\qos\logback\logback-classic\1.2.3\logback-classic-1.2.3.jar;D:\software\apache-maven-3.6.1\mvn_resp\ch\qos\logback\logback-core\1.2.3\logback-core-1.2.3.jar;D:\software\apache-maven-3.6.1\mvn_resp\org\apache\logging\log4j\log4j-to-slf4j\2.13.3\log4j-to-slf4j-2.13.3.jar;D:\software\apache-maven-3.6.1\mvn_resp\org\apache\logging\log4j\log4j-api\2.13.3\log4j-api-2.13.3.jar;D:\software\apache-maven-3.6.1\mvn_resp\org\slf4j\jul-to-slf4j\1.7.30\jul-to-slf4j-1.7.30.jar;D:\software\apache-maven-3.6.1\mvn_resp\jakarta\annotation\jakarta.annotation-api\1.3.5\jakarta.annotation-api-1.3.5.jar;D:\software\apache-maven-3.6.1\mvn_resp\org\yaml\snakeyaml\1.27\snakeyaml-1.27.jar;D:\software\apache-maven-3.6.1\mvn_resp\org\springframework\boot\spring-boot-starter-json\2.4.1\spring-boot-starter-json-2.4.1.jar;D:\software\apache-maven-3.6.1\mvn_resp\com\fasterxml\jackson\core\jackson-databind\2.11.3\jackson-databind-2.11.3.jar;D:\software\apache-maven-3.6.1\mvn_resp\com\fasterxml\jackson\core\jackson-annotations\2.11.3\jackson-annotations-2.11.3.jar;D:\software\apache-maven-3.6.1\mvn_resp\com\fasterxml\jackson\core\jackson-core\2.11.3\jackson-core-2.11.3.jar;D:\software\apache-maven-3.6.1\mvn_resp\com\fasterxml\jackson\datatype\jackson-datatype-jdk8\2.11.3\jackson-datatype-jdk8-2.11.3.jar;D:\software\apache-maven-3.6.1\mvn_resp\com\fasterxml\jackson\datatype\jackson-datatype-jsr310\2.11.3\jackson-datatype-jsr310-2.11.3.jar;D:\software\apache-maven-3.6.1\mvn_resp\com\fasterxml\jackson\module\jackson-module-parameter-names\2.11.3\jackson-module-parameter-names-2.11.3.jar;D:\software\apache-maven-3.6.1\mvn_resp\org\springframework\boot\spring-boot-starter-tomcat\2.4.1\spring-boot-starter-tomcat-2.4.1.jar;D:\software\apache-maven-3.6.1\mvn_resp\org\apache\tomcat\embed\tomcat-embed-core\9.0.41\tomcat-embed-core-9.0.41.jar;D:\software\apache-maven-3.6.1\mvn_resp\org\glassfish\jakarta.el\3.0.3\jakarta.el-3.0.3.jar;D:\software\apache-maven-3.6.1\mvn_resp\org\apache\tomcat\embed\tomcat-embed-websocket\9.0.41\tomcat-embed-websocket-9.0.41.jar;D:\software\apache-maven-3.6.1\mvn_resp\org\springframework\spring-web\5.3.2\spring-web-5.3.2.jar;D:\software\apache-maven-3.6.1\mvn_resp\org\springframework\spring-beans\5.3.2\spring-beans-5.3.2.jar;D:\software\apache-maven-3.6.1\mvn_resp\org\springframework\spring-webmvc\5.3.2\spring-webmvc-5.3.2.jar;D:\software\apache-maven-3.6.1\mvn_resp\org\springframework\spring-aop\5.3.2\spring-aop-5.3.2.jar;D:\software\apache-maven-3.6.1\mvn_resp\org\springframework\spring-context\5.3.2\spring-context-5.3.2.jar;D:\software\apache-maven-3.6.1\mvn_resp\org\springframework\spring-expression\5.3.2\spring-expression-5.3.2.jar;D:\software\apache-maven-3.6.1\mvn_resp\org\projectlombok\lombok\1.18.16\lombok-1.18.16.jar;D:\software\apache-maven-3.6.1\mvn_resp\com\baomidou\mybatis-plus-boot-starter\3.4.3\mybatis-plus-boot-starter-3.4.3.jar;D:\software\apache-maven-3.6.1\mvn_resp\com\baomidou\mybatis-plus\3.4.3\mybatis-plus-3.4.3.jar;D:\software\apache-maven-3.6.1\mvn_resp\com\baomidou\mybatis-plus-extension\3.4.3\mybatis-plus-extension-3.4.3.jar;D:\software\apache-maven-3.6.1\mvn_resp\com\baomidou\mybatis-plus-core\3.4.3\mybatis-plus-core-3.4.3.jar;D:\software\apache-maven-3.6.1\mvn_resp\com\baomidou\mybatis-plus-annotation\3.4.3\mybatis-plus-annotation-3.4.3.jar;D:\software\apache-maven-3.6.1\mvn_resp\com\github\jsqlparser\jsqlparser\4.0\jsqlparser-4.0.jar;D:\software\apache-maven-3.6.1\mvn_resp\org\mybatis\mybatis\3.5.7\mybatis-3.5.7.jar;D:\software\apache-maven-3.6.1\mvn_resp\org\mybatis\mybatis-spring\2.0.6\mybatis-spring-2.0.6.jar;D:\software\apache-maven-3.6.1\mvn_resp\org\springframework\boot\spring-boot-autoconfigure\2.4.1\spring-boot-autoconfigure-2.4.1.jar;D:\software\apache-maven-3.6.1\mvn_resp\org\springframework\boot\spring-boot-starter-jdbc\2.4.1\spring-boot-starter-jdbc-2.4.1.jar;D:\software\apache-maven-3.6.1\mvn_resp\com\zaxxer\HikariCP\3.4.5\HikariCP-3.4.5.jar;D:\software\apache-maven-3.6.1\mvn_resp\org\springframework\spring-jdbc\5.3.2\spring-jdbc-5.3.2.jar;D:\software\apache-maven-3.6.1\mvn_resp\org\springframework\spring-tx\5.3.2\spring-tx-5.3.2.jar;D:\software\apache-maven-3.6.1\mvn_resp\mysql\mysql-connector-java\8.0.22\mysql-connector-java-8.0.22.jar;D:\software\apache-maven-3.6.1\mvn_resp\org\slf4j\slf4j-api\1.7.30\slf4j-api-1.7.30.jar;D:\software\apache-maven-3.6.1\mvn_resp\org\springframework\spring-core\5.3.2\spring-core-5.3.2.jar;D:\software\apache-maven-3.6.1\mvn_resp\org\springframework\spring-jcl\5.3.2\spring-jcl-5.3.2.jar" com.project.care.IntelligentElderlyCareApplication
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.4.1)
2023-07-16 17:30:39.622 INFO 10292 --- [ main] c.p.c.IntelligentElderlyCareApplication : Starting IntelligentElderlyCareApplication using Java 1.8.0_131 on 潘 with PID 10292 (D:\IDEA\Intelligent elderly care\target\classes started by Hu in D:\IDEA\Intelligent elderly care)
2023-07-16 17:30:39.628 INFO 10292 --- [ main] c.p.c.IntelligentElderlyCareApplication : No active profile set, falling back to default profiles: default
2023-07-16 17:30:40.754 INFO 10292 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8003 (http)
2023-07-16 17:30:40.761 INFO 10292 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2023-07-16 17:30:40.761 INFO 10292 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.41]
2023-07-16 17:30:40.829 INFO 10292 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2023-07-16 17:30:40.829 INFO 10292 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1140 ms
Logging initialized using 'class org.apache.ibatis.logging.stdout.StdOutImpl' adapter.
2023-07-16 17:30:40.968 WARN 10292 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userRegisterController': Unsatisfied dependency expressed through field 'userRegisterService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userRegisterServiceImpl': Unsatisfied dependency expressed through field 'baseMapper'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userRegisterDao' defined in file [D:\IDEA\Intelligent elderly care\target\classes\com\project\care\dao\UserRegisterDao.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [com/baomidou/mybatisplus/autoconfigure/MybatisPlusAutoConfiguration.class]: Unsatisfied dependency expressed through method 'sqlSessionFactory' 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 org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Failed to determine a suitable driver class
2023-07-16 17:30:40.971 INFO 10292 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2023-07-16 17:30:40.984 INFO 10292 --- [ main] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2023-07-16 17:30:40.998 ERROR 10292 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.
Reason: Failed to determine a suitable driver class
Action:
Consider the following:
If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active).
Process finished with exit code 1
根据错误信息可知是数据库的连接出了问题,排除数据库的连接url,用户名称,和密码都没问题时还是出现上述错误。
我的错误解决方法
在排除众多问题后,发现我的pom.xml中忘记导入相关依赖。
添加下述代码
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>1.2.6</version>
</dependency>
并点击
运行成功