[英]Spring boot dependency error for some of the dependencies in maven
Below is my pom.xml下面是我的 pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.java.hackathon</groupId>
<artifactId>com.java.hackathon</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>com.java.hackathon</name>
<url>http://maven.apache.org</url>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>3.6.0.1398</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<version>1.5.0</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- junit 5 -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit-jupiter.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.0</version>
<executions>
<execution>
<id>default-prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>default-report</id>
<phase>prepare-package</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Error message i am getting is我收到的错误消息是
For artifact {org.springframework.boot:spring-boot-starter-data-jpa:null:jar}: The version cannot be empty. (org.apache.maven.plugins:maven-resources-
plugin:2.6:testResources:default-testResources:process-test-resources) org.apache.maven.artifact.InvalidArtifactRTException: For artifact
{org.springframework.boot:spring-boot-starter-data-jpa:null:jar}: The version cannot be empty. at
But in most of the cases what I observed most of them wont declare any version for spring-boot-starter-data-jpa and spring-boot-starter-web but i am getting these errors I am getting errors for all the dependencies where i had not declared version但是在大多数情况下,我观察到的大多数情况下都不会为 spring-boot-starter-data-jpa 和 spring-boot-starter-web 声明任何版本,但是我收到了这些错误我收到了所有依赖项的错误我没有声明版本
So i want to know how to resolve these errors where version has not been declared or any plugins needed to be downloaded.所以我想知道如何解决未声明版本或需要下载任何插件的这些错误。 I am executing the code in eclipse.
我正在执行 eclipse 中的代码。
Normally you don't declare dependency versions when you have defined a dependencyManagement
section in your POM where you centralize all of the dependencies used by all of your modules.通常,当您在 POM 中定义了一个
dependencyManagement
部分时,您不会声明依赖项版本,您可以在其中集中所有模块使用的所有依赖项。
Since your POM does not define a dependencyManagement
, you will need to provide the version for each dependency.由于您的 POM 没有定义
dependencyManagement
,因此您需要为每个依赖项提供版本。 You can check this sample guide project from Spring Boot, where you will notice that they set a parent in the POM:您可以从 Spring Boot 中查看此示例指南项目,您会注意到他们在 POM 中设置了父项:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.4.2</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
This parent will cause the POM to inherit a dependencyManagement
section containing all of the versions of the spring-boot-starter-xx
dependencies.这个父级将导致 POM 继承一个包含
spring-boot-starter-xx
依赖项的所有版本的dependencyManagement
部分。
More details: https://docs.spring.io/spring-boot/docs/current/reference/html/using-spring-boot.html#using-boot-dependency-management更多详细信息: https://docs.spring.io/spring-boot/docs/current/reference/html/using-spring-boot.html#using-boot-dependency-management
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.