不可解析的父POM:无法传输工件org.springframework.boot:spring-boot-dependencies:pom

时间:2018-04-22 14:48:05

标签: java maven spring-boot

这是我从here

复制的pom.xml
<groupId>com.example</groupId>
<artifactId>myproject</artifactId>
<version>0.0.1-SNAPSHOT</version>

<dependencyManagement>
<dependencies>
    <!-- Override Spring Data release train provided by Spring Boot -->
    <dependency>
        <groupId>org.springframework.data</groupId>
        <artifactId>spring-data-releasetrain</artifactId>
        <version>Fowler-SR2</version>
        <type>pom</type>
        <scope>import</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-dependencies</artifactId>
        <version>2.1.0.BUILD-SNAPSHOT</version>
        <type>pom</type>
        <scope>import</scope>
    </dependency>
</dependencies>

<!-- Additional lines to be added here... -->

<!-- (you don't need this if you are using a .RELEASE version) -->
<repositories>
    <repository>
        <id>spring-snapshots</id>
        <url>https://repo.spring.io/snapshot</url>
        <snapshots><enabled>true</enabled></snapshots>
    </repository>
    <repository>
        <id>spring-milestones</id>
        <url>https://repo.spring.io/milestone</url>
    </repository>
</repositories>
<pluginRepositories>
    <pluginRepository>
        <id>spring-snapshots</id>
        <url>https://repo.spring.io/snapshot</url>
    </pluginRepository>
    <pluginRepository>
        <id>spring-milestones</id>
        <url>https://repo.spring.io/milestone</url>
    </pluginRepository>
</pluginRepositories>

当我在命令行中编写mvn包时,我收到以下错误:

不可解析的导入POM:无法传输工件org.springframework.boot:spring-boot-dependencies:pom:2.1.0.BUILD-SNAPSHOT from / to spring-snapshots https://repo.spring.io/snapshot proxy.example.com @line 20第15栏

我还在home / .m2中添加了一个settings.xml,其中包含以下代码

<proxies>
   <proxy>
      <id>example-proxy</id>
      <active>true</active>
      <protocol>http</protocol>
      <host>proxy.example.com</host>
      <port>8080</port>          
      <nonProxyHosts>www.google.com|*.example.com</nonProxyHosts>
    </proxy>
  </proxies>

1 个答案:

答案 0 :(得分:0)

我遇到了同样的问题。通过在Java版本1.8的POM中添加maven-compiler-plugin并通过Maven强制更新来解决此问题。

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <configuration>
      <source>1.8</source>
      <target>1.8</target>
    </configuration>
</plugin>

最初,我通过IDE将Web项目的JRE系统库从SE 1.5配置为1.8。但是从Maven更新项目(项目-> Maven->更新)后,系统库自动返回到旧版本-1.5。

由于Spring Boot 2.1.0需要JDK 1.8+,因此添加了编译器插件并更新了项目。奏效了。