Spring boot 未能配置数据源:';url';未指定属性,无法配置嵌入式数据源。Gradle项目中出现错误
我已经创建了一个新的Spring Boot Gradle项目。没有编码,我还没有做。但是我在以Spring Boot的方式运行应用程序时遇到了错误。我需要在这里添加任何其他依赖项吗?或者,解决这个问题的办法是什么 build.gradleSpring boot 未能配置数据源:';url';未指定属性,无法配置嵌入式数据源。Gradle项目中出现错误,spring-boot,tomcat,gradle,build.gradle,Spring Boot,Tomcat,Gradle,Build.gradle,我已经创建了一个新的Spring Boot Gradle项目。没有编码,我还没有做。但是我在以Spring Boot的方式运行应用程序时遇到了错误。我需要在这里添加任何其他依赖项吗?或者,解决这个问题的办法是什么 build.gradle plugins { id 'org.springframework.boot' version '2.3.3.RELEASE' id 'io.spring.dependency-management' version '1.0.10.RELEA
plugins {
id 'org.springframework.boot' version '2.3.3.RELEASE'
id 'io.spring.dependency-management' version '1.0.10.RELEASE'
id 'java'
}
group = 'com.informationbook'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-batch'
implementation 'org.springframework.boot:spring-boot-starter-web'
testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
}
testImplementation 'org.springframework.batch:spring-batch-test'
}
test {
useJUnitPlatform()
}
这里我包括控制台,以供参考
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.3.3.RELEASE)
2020-08-29 10:07:44.398 INFO 18616 --- [ main] c.i.InformationBookApplication : Starting InformationBookApplication on LAPTOP-I4F37P4O with PID 18616 (C:\Users\mitad\Documents\STS_Workspace\Information-Book\bin\main started by mitad in C:\Users\mitad\Documents\STS_Workspace\Information-Book)
2020-08-29 10:07:44.400 INFO 18616 --- [ main] c.i.InformationBookApplication : No active profile set, falling back to default profiles: default
2020-08-29 10:07:44.892 INFO 18616 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2020-08-29 10:07:44.897 INFO 18616 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2020-08-29 10:07:44.897 INFO 18616 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.37]
2020-08-29 10:07:44.945 INFO 18616 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2020-08-29 10:07:44.945 INFO 18616 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 523 ms
2020-08-29 10:07:45.040 INFO 18616 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2020-08-29 10:07:45.114 WARN 18616 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: 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
2020-08-29 10:07:45.114 INFO 18616 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Shutting down ExecutorService 'applicationTaskExecutor'
2020-08-29 10:07:45.116 INFO 18616 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2020-08-29 10:07:45.123 INFO 18616 --- [ main] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-08-29 10:07:45.124 ERROR 18616 --- [ 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).
请运行Gradle dependency并检查dependency tree,控制台将打印
Run gradle dependency , console will print your dependency tree,
+--org.springframework.boot:springbootstarterbatch->2.3.3.RELEASE
|+---org.springframework.boot:springbootstarter:2.3.(*)
||+---雅加达。注释:雅加达。注释api:1.3.5
||+---org.springframework:spring核心:5.2.8.RELEASE(*)
|org.yaml:snakeyaml:1.26
|+---org.springframework.boot:springbootstarter jdbc:2.3.3.RELEASE