【发布时间】:2023-02-07 23:13:40
【问题描述】:
数小时以来,我一直在通过堆栈溢出中的许多位置调查此错误,但未能找到解决方案。我在 Udemy 上,从初学者到大师春季靴子课程。当我尝试运行它所说的代码时,我目前遇到了一个问题。
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.1.2.RELEASE)
2023-02-05 23:04:17.604 INFO 10908 --- [ restartedMain] g.s.s.Spring5webappApplication : Starting Spring5webappApplication on JeffGamingPC with PID 10908 (C:\Users\Jeff\git\spring5webapp\target\classes started by Jeff in C:\Users\Jeff\git\spring5webapp)
2023-02-05 23:04:17.607 INFO 10908 --- [ restartedMain] g.s.s.Spring5webappApplication : No active profile set, falling back to default profiles: default
2023-02-05 23:04:17.659 INFO 10908 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2023-02-05 23:04:17.659 INFO 10908 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
2023-02-05 23:04:18.702 INFO 10908 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data repositories in DEFAULT mode.
2023-02-05 23:04:18.766 INFO 10908 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 56ms. Found 3 repository interfaces.
2023-02-05 23:04:19.196 INFO 10908 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$55aeea2d] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2023-02-05 23:04:19.502 INFO 10908 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2023-02-05 23:04:19.523 INFO 10908 --- [ restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2023-02-05 23:04:19.523 INFO 10908 --- [ restartedMain] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.14]
2023-02-05 23:04:19.534 INFO 10908 --- [ restartedMain] o.a.catalina.core.AprLifecycleListener : The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [C:\Program Files\Java\jdk-17\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\Program Files\Common Files\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Users\Jeff;C:\Program Files\apache-maven-3.8.7\bin;C:\Program Files\gradle-7.3.2\bin;C:\WINDOWS\system32\git;C:\Program Files\Git\cmd;C:\Users\Jeff\AppData\Local\Microsoft\WindowsApps;C:\Users\Jeff\AppData\Local\Programs\Microsoft VS Code\bin;C:\Windows\system32;C:\Windows\System32\Wbem;C:\Windows;C:\WINDOWS\system32\git;C:\Users\Jeff\AppData\Local\GitHubDesktop\bin;.]
2023-02-05 23:04:19.623 INFO 10908 --- [ restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2023-02-05 23:04:19.623 INFO 10908 --- [ restartedMain] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1964 ms
2023-02-05 23:04:19.795 ERROR 10908 --- [ restartedMain] o.s.b.web.embedded.tomcat.TomcatStarter : Error starting Tomcat context. Exception: org.springframework.beans.factory.BeanCreationException. Message: Error creating bean with name 'servletEndpointRegistrar' defined in class path resource [org/springframework/boot/actuate/autoconfigure/endpoint/web/ServletEndpointManagementContextConfiguration$WebMvcServletEndpointManagementContextConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.actuate.endpoint.web.ServletEndpointRegistrar]: Factory method 'servletEndpointRegistrar' threw exception; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'healthEndpoint' defined in class path resource [org/springframework/boot/actuate/autoconfigure/health/HealthEndpointConfiguration.class]: Unsatisfied dependency expressed through method 'healthEndpoint' parameter 1; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'healthIndicatorRegistry' defined in class path resource [org/springframework/boot/actuate/autoconfigure/health/HealthIndicatorAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.actuate.health.HealthIndicatorRegistry]: Factory method 'healthIndicatorRegistry' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.actuate.autoconfigure.jdbc.DataSourceHealthIndicatorAutoConfiguration': Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.actuate.autoconfigure.jdbc.DataSourceHealthIndicatorAutoConfiguration$$EnhancerBySpringCGLIB$$c4933bb3]: Constructor threw exception; 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-02-05 23:04:19.820 INFO 10908 --- [ restartedMain] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2023-02-05 23:04:19.825 WARN 10908 --- [ restartedMain] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
2023-02-05 23:04:19.836 INFO 10908 --- [ restartedMain] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2023-02-05 23:04:19.838 ERROR 10908 --- [ restartedMain] 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).
这是我遇到此问题的 github 存储库的链接。 https://github.com/jeffhennen/spring5webapp
我尝试了许多不同的事情来解决这个问题。我尝试了也收到错误的教授代码。我试图将 java 版本更改为许多不同的类型,从 java 8、11(教授将其作为他们的 JDK)、17(这是我为我的 springboot 创建和使用的)。
我尝试了以下方法:
- 我安装了 jdk 17,我安装了 JDK 11 并卸载了 JDK 17
- 调整了POM中的java版本
- 根据其他堆栈溢出问题调整了依赖关系。
- 将
"management.health.defaults.enabled=false"添加到应用程序属性。 - 没有使用Mysql所以不知道如何调整数据库信息
- 尝试将@springbootapplication 更改为
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class }),但这导致了错误
【问题讨论】:
标签: java spring spring-boot