我有要使用Maven在Intellij中导入的Java API,这就是我得到的:
无法解析插件org.springframework.boot:spring-boot-maven-plugin:
这是我的pom.xml文件:
<?xml version="1.0" encoding="UTF-8"?>
<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>sample</groupId>
<artifactId>sample-parent</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>${project.artifactId}</name>
<description>Parent </description>
<modules>
<module>sample-repository-mongo</module>
<module>sample-service</module>
<module>sample-webservice</module>
</modules>
<prerequisites>
<maven>3</maven>
</prerequisites>
<properties>
<framework.version>0.0.0</framework.version>
</properties>
<dependencyManagement>
<dependencies>
<!-- Module dependencies -->
<dependency>
<groupId>eu.everis.cordis.sample</groupId>
<artifactId>sample-webservice</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>eu.everis.cordis.sample</groupId>
<artifactId>sample-service</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>eu.everis.cordis.sample</groupId>
<artifactId>sample-repository-mongo</artifactId>
<version>${project.version}</version>
</dependency>
<!-- Spring dependencies -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.3.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<!-- JSON -->
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.5</version>
</dependency>
<!-- Unit Testing -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
<!-- Logging -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.11.0</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.11.0</version>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
</dependencies>
<build>
<!-- <finalName>${warname}</finalName> -->
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
<outputDirectory>.</outputDirectory>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
到目前为止,我能找到的关于类似问题的唯一线索是this one 我从那里尝试了最新版本的解决方案,不幸的是它没有帮助。
我有用于项目结构的Java 8,并且我也尝试过使用Maven 3.6.2和3.6.1,因为一段时间前,我能够使用Maven 3.6.1将其导入另一台笔记本电脑。
我已经仔细检查了java和maven环境变量,我知道它们还可以。我也尝试过运行mvn clean install, mvn install, mvn package, mvn validate
和我可以找到的任何其他命令,但问题仍然相同。
答案 0 :(得分:1)
这是一个Spring启动项目,所以pom must have a parent。只需将这些行添加到pom.xml的顶部:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.3</version>
</parent>
此父级将处理依赖项的版本。
答案 1 :(得分:1)
我的版本为 2.3.4 ,这在我的IntelliJ IDEA 2019.3.1(最终版)中引起了问题。将其更改回 2.3.2 可以为我解决此问题。现在我有以下配置:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.2.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>