【发布时间】:2020-01-21 05:34:15
【问题描述】:
我有 java api,我正在尝试使用 Maven 在 Intellij 中导入,这就是我得到的:
无法解析插件 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 和我能找到的任何其他命令,但问题仍然存在。
【问题讨论】:
-
你能试试
mvn -U clean install- 强制更新依赖吗? -
您显示的 pom 是您的父 pom,对吗?那为什么你有一个 build 部分而不是一个 pluginManagement 部分,就像你的依赖项一样?
-
而且这个 pom 没有父工件。通常,Spring 引导项目将工件
spring-boot-starter-parent作为父项,而不是常规依赖项。 -
我尝试运行
mvn -U clean install,但它没有改变,它告诉我一个关于编码的错误并且仍然显示一堆错误。是的。这是 3 个模块的父 pom,我并不真正了解 Maven,我知道我之前导入了这个项目并且它有效,但我现在不知道是什么问题。父 pom 的结构应该不同吗? -
你能添加确切的错误信息吗?
标签: spring maven intellij-idea