LoginSignup
1
5

More than 5 years have passed since last update.

プロキシ環境下でMavenProjectを作成するときのProxy設定

Posted at

背景

Spring Tool Suite(STS)でMavenProjectを作成しようとしたら以下のエラーが発生、Proxy設定を行ったら解消したのでProxy設定方法を記載します。

Could not resolve archetype org.apache.maven.archetypes:maven-archetype-plugin:1.2 from any of the configured repositories.
Could not resolve artifact org.apache.maven.archetypes:maven-archetype-plugin:pom:1.2
Could not transfer artifact org.apache.maven.archetypes:maven-archetype-plugin:pom:1.2 from/to central (https://repo.maven.apache.org/maven2): connect timed out
Could not transfer artifact org.apache.maven.archetypes:maven-archetype-plugin:pom:1.2 from/to central (https://repo.maven.apache.org/maven2): connect timed out

環境

・Windows10
・Spring Tool Suite(3.9.5Release)

Proxy設定方法

STSを開き、「ウィンドウ>設定」から設定画面を表示する。

設定画面から「Maven>ユーザ設定」を表示し、「ユーザ設定(ファイルを開く)」でファイルをオープンする。

image.png

ファイルを開いたらタグを追加し、Proxyの設定を行う。

<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd">
  <proxies>
    <proxy>
      <id>http_proxy</id>
      <active>true</active>
      <protocol>http</protocol>
      <host>xxxxx</host>
      <port>8080</port>
    </proxy>
    <proxy>
      <id>https_proxy</id>
      <active>true</active>
      <protocol>https</protocol>
      <host>xxxxx</host>
      <port>8080</port>
    </proxy>
  </proxies>
</settings>

ファイルを保存して再度設定画面から「Maven>ユーザ設定」を開き設定の更新ボタンをクリック

Mavenキャッシュのクリア

一度プロジェクトの作成を試みている場合は、キャッシュにごみが出いているので削除する。私の場合は「maven-archetype-plugin」のアーキタイプの作成に失敗したので以下のフォルダを削除

C:\Users\admin\.m2\repository\org\apache\maven\archetypes\maven-archetype-plugin

MavenProjectの作成

再度プロジェクトの作成を行い、作成できることを確認する。

1
5
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
5