0
1

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 3 years have passed since last update.

CentOSにMavenをインストールする方法

Last updated at Posted at 2020-04-02
  • 環境
    • CentOS Linux release 7.6.1810 (Core)
    • tar (GNU tar) 1.26
    • GNU Wget 1.14 built on linux-gnu.

アーカイブをダウンロードする

# 1. rootユーザーに切り替える
$ sudo su -
[sudo] password for ponsuke: 

# 2. ダウンロードする
# wget https://www.apache.org/dist/maven/maven-3/3.2.5/binaries/apache-maven-3.2.5-bin.tar.gz
--2020-04-02 16:32:40--  https://www.apache.org/dist/maven/maven-3/3.2.5/binaries/apache-maven-3.2.5-bin.tar.gz
Resolving www.apache.org (www.apache.org)... 40.79.78.1, 95.216.24.32, 2a01:4f9:2a:185f::2
...省略...
100%[=========================================================================================================================================================================>] 7,956,528   2.58MB/s   in 2.9s   

2020-04-02 16:33:48 (2.58 MB/s) - ‘apache-maven-3.2.5-bin.tar.gz’ saved [7956528/7956528]

解凍して配置する

# tar xzvf apache-maven-3.2.5-bin.tar.gz -C /opt/
apache-maven-3.2.5/README.txt
...省略...
apache-maven-3.2.5/lib/slf4j-simple-1.7.5.jar

パスを通す

# 1. rootユーザーから自分に切り替える
# exit
logout

# 2. .bash_profileにパスを設定する
$ vi ~/.bash_profile
↓これを追記する
PATH=$PATH:/opt/apache-maven-3.2.5/bin/
↓これより前に↑これを書く
export PATH

# 3. .bash_profileを反映する
$ source ~/.bash_profile 
[1]+  Done                    exec ibus-daemon -dx

# 4. PATHを確認する
$ printenv PATH
/sbin:/bin:...省略...:/opt/apache-maven-3.2.5/bin/

Mavenが使えるか確認するためにバージョンを見てみる

# 注意 : コマンドはmavenではない
$ maven --version
bash: maven: command not found

# mvnが正しい
$ mvn --version
Apache Maven 3.2.5 (12a6b3acb947671f09b81f49094c53f426d8cea1; 2014-12-15T02:29:23+09:00)
Maven home: /opt/apache-maven-3.2.5
Java version: 1.8.0_212, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.212.b04-0.el7_6.x86_64/jre
Default locale: ja_JP, platform encoding: UTF-8
OS name: "linux", version: "3.10.0-957.12.2.el7.x86_64", arch: "amd64", family: "unix"
0
1
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
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?