Maven 依存パッケージインストール先の設定
Eclipse 抜きで Maven を独立に使う際に
Maven グローバル設定ファイルを編集しパッケージインストール先を変更する
グローバル設定ファイルは <Maven_インストール先>/conf/setting.xml
である(インストールディレクトリは bin
ディレクトリがある場所である)。
xml
<!-- <maven_install_direcotry>/conf/setting.xml-->
<?xml version="1.0" encoding="UTF-8"?>
<!-- ... -->
<settings xmlns="http://maven.apache.org/SETTINGS/1.2.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.2.0 https://maven.apache.org/xsd/settings-1.2.0.xsd">
<!-- localRepository
| The path to the local repository maven will use to store artifacts.
|
| Default: ${user.home}/.m2/repository
-->
<!-- この行を編集しインストール先を変更する(初期状態時この行は前文の註釈にある) -->
<localRepository>E:\SOFT\programming\package-manage\maven\apache-maven-3.9.6\repository</localRepository>
<!-- ... -->
</settings>
コマンドラインで設定ファイルの情報を確認する
mvn help:effective-settings
命令で Mave 有効設定情報をプリントする。この命令は全ての設定ファイルを配慮する。(グローバル settings.xml
ファイル、ユーザー settings.xml
ファイル、プロジェクト pom.xml
ファイル)。
shell
PS maven> mvn help:effective-settings
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------< org.apache.maven:standalone-pom >-------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] --- help:3.4.0:effective-settings (default-cli) @ standalone-pom ---
[INFO]
Effective user-specific configuration settings:
<?xml version="1.0" encoding="UTF-8"?>
<!-- ====================================================================== -->
<!-- -->
<!-- Generated by Maven Help Plugin -->
<!-- See: https://maven.apache.org/plugins/maven-help-plugin/ -->
<!-- -->
<!-- ====================================================================== -->
<settings xmlns="http://maven.apache.org/SETTINGS/1.2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.2.0 http://maven.apache.org/xsd/settings-1.2.0.xsd">
<localRepository>E:\SOFT\programming\package-manage\maven\apache-maven-3.9.6\repository</localRepository>
<mirrors>
<mirror>
<mirrorOf>external:http:*</mirrorOf>
<name>Pseudo repository to mirror external repositories initially using HTTP.</name>
<url>http://0.0.0.0/</url>
<blocked>true</blocked>
<id>maven-default-http-blocker</id>
</mirror>
</mirrors>
<pluginGroups>
<pluginGroup>org.apache.maven.plugins</pluginGroup>
<pluginGroup>org.codehaus.mojo</pluginGroup>
</pluginGroups>
</settings>
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.645 s
[INFO] Finished at: 2024-02-20T00:28:45+09:00
[INFO] ------------------------------------------------------------------------
使用 Eclipse 内置 Maven 工具时
メニュー > Window > Preferences
から環境設定ウィンドウを開く。サイドバーから Maven > User Settings
を見つけ、中の Global Settings
或いは User Settings
にカスタムの settings.xml
文件を設置する(設定内容は <Maven_インストール先>/conf/setting.xml
ファイルを参照できる)。Update Settings
のクリック後、Local Repository
が自動に更新される(手動編集不可)。Apply
のクリック後に適応される。