简体   繁体   English

Gradle 不处理依赖项 - Java Spring 引导

[英]Gradle doesn't handle dependencies - Java Spring boot

I'm working on a Spring Boot 2.2.1 project.我正在研究Spring Boot 2.2.1 项目。 I use Gradle 6.8.3 as a dependency manager, I'm new to working with Gradle as a deps manager and it's my first time using the h2 engine.我使用Gradle 6.8.3作为依赖管理器,我是使用 Gradle 作为依赖管理器的新手,这是我第一次使用 h2 引擎。

This is my gradle file这是我的 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()
}

In my application.properties I have a path that points to memory H2在我的 application.properties 中,我有一条指向 memory H2 的路径

application.properties应用程序属性

spring.datasource.url=jdbc:h2:mem:~/biblioteca

Cuando ejecuto mi aplicación, e ingreso la url me genera la siguiente excepción: Cuando ejecuto mi aplicación, e ingreso la url me Genera la siguiente excepción:

IO Exception: null
IO Exception: null [90028-200] 90028/90028 (Help)

I've searched for this on the internet for a few hours, and I have no information about it, something leads me to believe that Gradle is not taking my dependencies.我已经在互联网上搜索了几个小时,但我没有关于它的信息,这让我相信 Gradle 没有接受我的依赖。 When I bring up my server I get the following in the powershell当我启动我的服务器时,我在 powershell 中得到以下信息

     .   ____          _            __ _ _   
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \  
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ 
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / / 
 =========|_|==============|___/=/_/_/_/  
 :: 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)

Should dependencies be shown here if I'm not wrong?如果我没记错的话,这里应该显示依赖关系吗? I already tried with mvn clean install and the server continues to get up the same我已经尝试使用mvn clean install并且服务器继续启动相同

Add other h2 properties needed to connect to the database in application.properties在 application.properties 中添加连接数据库所需的其他 h2 属性

spring.datasource.driverClassName=org.h2.Driver
spring.datasource.username=
spring.datasource.password=
spring.jpa.hibernate.ddl-auto=

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM