web-dev-qa-db-ja.com

解決できないインポートPOMが見つかりません

親pomでモジュールのような春のブーツを試してみましたが、エラーが発生しました

[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[ERROR] Non-resolvable import POM: Failure to find org.springframework.boot:spring-boot-dependencies:pom:2.0.0.M6 in https://repo.maven.Apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced @ line 30, column 19
 @ 
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]   
[ERROR]   The project mydomain.project:main-project:1.0-SNAPSHOT (D:\gitProjects\main-server\sources\pom.xml) has 1 error
[ERROR]     Non-resolvable import POM: Failure to find org.springframework.boot:spring-boot-dependencies:pom:2.0.0.M6 in https://repo.maven.Apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced @ line 30, column 19 -> [Help 2]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.Apache.org/confluence/display/MAVEN/ProjectBuildingException
[ERROR] [Help 2] http://cwiki.Apache.org/confluence/display/MAVEN/UnresolvableModelException

.m2ローカルリポジトリでmyprojectを削除しようとしました

私は2つのモジュール(単純なJavaとスプリングブート)を含むmavenプロジェクトを持っています。dependensyManagmentのように親をスプリングブートからメインpomに抽出し、括弧をスプリングブートに設定します。その後、これを取得しますエラー

変更を元に戻し、すべて正常に動作します。一歩一歩私はすべてがつぶれるときにポイントを失神させます

  1. これをメインのポンに追加します
<dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-dependencies</artifactId>
        <version>2.0.0.M6</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>   </dependencyManagement>
  1. 春のブーツでこれを変えます
<parent>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-parent</artifactId>
      <version>2.0.0.M6</version>
      <relativePath/> <!-- lookup parent from repository -->
  </parent>

これに:

<parent>
        <artifactId>main-project</artifactId>
        <groupId>main.project</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>
7
ip696

バージョン2.0.0.M6はリポジトリ http://repo.maven.Apache.org/maven2 にありません。このバージョンを使用したくない場合は、Mavenリポジトリ http://repo.spring.io/milestone を使用する必要があります。それをPOMファイルに追加します。

<repositories>
    <repository>
        <id>spring-milestone-repo</id>
        <url>http://repo.spring.io/milestone/</url>
    </repository>
</repositories>

マイルストーンバージョンではなく、spring-bootの最新リリースバージョン(1.5.8.RELEASE)を使用することをお勧めします。 POMがどのように見えるかはわかりませんが、POMでスプリングブートをさまざまな方法で定義できます。

1. Spring Bootの親POMを使用する

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.5.8.RELEASE</version>
</parent>

次に、使用したい依存関係を追加できます。例:

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
</dependencies>

参照: https://spring.io/guides/gs/spring-boot/

2.依存関係管理でスプリングブートを宣言する

すでに独自の親POMを使用している場合は、POMにスプリングブート依存関係管理をインポートすることもできます。

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-dependencies</artifactId>
            <version>1.5.8.RELEASE</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

バリアント#1と同じように、使用したいスプリングブートの依存関係を後で宣言できます。

8
ph1l