Spring Boot项目Gradle依赖异常及H2数据库连接IO错误排查
问题:Spring Boot + H2数据库启动后访问出现IO Exception异常
项目基本信息
- Spring Boot版本:2.2.1.RELEASE
- Gradle版本:6.8.3
- JDK版本:1.8
- 使用H2内存数据库,首次接触Gradle和H2
build.gradle配置
plugins { id 'org.springframework.boot' version '2.2.1.RELEASE' id 'io.spring.dependency-management' version '1.0.11.RELEASE' id 'java' } group = 'com.somedomain' version = '0.0.1-SNAPSHOT' sourceCompatibility = '1.8' repositories { mavenCentral() } dependencies { implementation 'org.springframework.boot:spring-boot-starter' implementation 'org.springframework.boot:spring-boot-starter-web' runtimeOnly 'com.h2database:h2' testImplementation 'org.springframework.boot:spring-boot-starter-test' testImplementation 'org.springframework.boot:spring-boot-starter-web' } test { useJUnitPlatform() }
application.properties数据库配置
spring.datasource.url=jdbc:h2:mem:~/biblioteca
访问应用时出现的异常
IO Exception: null IO Exception: null [90028-200] 90028/90028 (Help)
应用启动日志
. ____ _ __ _ _ \/\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v2.2.1.RELEASE) 2022-09-07 17:01:40.086 INFO 8612 --- [ main] c.c.biblioteca.BibliotecaApplication : Starting BibliotecaApplication on LAPTOP-4E9PK22R with PID 8612 (C:\Users\tomas\OneDrive\Escritorio\projects\proyect\biblioteca\bin\main started by tomas in C:\Users\tomas\OneDrive\Escritorio\projects\proyect\biblioteca) 2022-09-07 17:01:40.093 INFO 8612 --- [ main] c.c.biblioteca.BibliotecaApplication : No active profile set, falling back to default profiles: default 2022-09-07 17:01:42.423 INFO 8612 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http) 2022-09-07 17:01:42.613 INFO 8612 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat] 2022-09-07 17:01:42.692 INFO 8612 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.27] 2022-09-07 17:01:43.227 INFO 8612 --- [ main] o.a.c.c.C.[Tomcat].[localhost]. [/] : Initializing Spring embedded WebApplicationContext 2022-09-07 17:01:43.229 INFO 8612 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 2874 ms 2022-09-07 17:01:43.829 INFO 8612 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor' 2022-09-07 17:01:44.318 INFO 8612 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path '' 2022-09-07 17:01:44.328 INFO 8612 --- [ main] c.c.biblioteca.BibliotecaApplication : Started BibliotecaApplication in 5.386 seconds (JVM running for 6.59)
疑问
- 启动日志未显示依赖相关信息,怀疑Gradle未正确加载H2依赖
- 尝试执行
mvn clean install(实际项目用Gradle,此处为操作混淆),问题未解决
内容的提问来源于stack exchange,提问作者Toms_Hd3z
相关产品推荐
相关产品推荐

