1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

対処法 : Could not resolve dependencies for project *: The following artifacts could not be resolved: com.google.guava:guava:bundle:31.1-jre

Last updated at Posted at 2023-03-31

状況

Mavenを使用した開発をVSCodeで行っていた。VSCodeの拡張機能 Maven for Java を使って"Guava"を依存先として追加したところ、pom.xmlに以下のように追記された。

pom.xml
    <dependency>
      <groupId>com.google.guava</groupId>
      <artifactId>guava</artifactId>
      <version>31.1-jre</version>
      <type>bundle</type>
    </dependency>

すると以下のようなエラーが発生した。

[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  1.093 s
[INFO] Finished at: 2023-04-01T00:31:50+09:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project demo: Could not resolve dependencies for project [プロジェクト名]: The following artifacts could not be resolved: com.google.guava:guava:bundle:31.1-jre (absent): com.google.guava:guava:bundle:31.1-jre was not found in https://repo.maven.apache.org/maven2 during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of central has elapsed or updates are forced -> [Help 1]
[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/DependencyResolutionException

解決策

<type>タグを取る。

pom.xml
    <dependency>
      <groupId>com.google.guava</groupId>
      <artifactId>guava</artifactId>
      <version>31.1-jre</version>
-      <type>bundle</type>
    </dependency>

これだけで動くようになった。

<type>bundle</type>という記述が何を意味しているのか調べてみたが、ネット上にはこれくらいの記述しかなかった。この記事によると、この記述があると.jarファイルにまとめてバンドルできるとか何とか。でもドキュメントを見てもbundleというタイプはなさそう。何だったのだろうか。

拡張機能を盲信してはならぬ。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?