| 知乎专栏 |
目录
http://maven.apache.org/
Rocky Linux 9 AppStream 没有
[root@development ~]# dnf install https://dl.rockylinux.org/pub/rocky/10/AppStream/x86_64/os/Packages/m/maven-openjdk25-3.9.9-3.el10_1.noarch.rpm
cat > /etc/java/maven.conf <<EOF JAVA_HOME=/usr/lib/jvm/jre-25-openjdk EOF
[root@development meeting]# mvn -v WARNING: A restricted method in java.lang.System has been called WARNING: java.lang.System::load has been called by org.fusesource.jansi.internal.JansiLoader in an unnamed module (file:/usr/share/maven/lib/jansi-1.17.1.jar) WARNING: Use --enable-native-access=ALL-UNNAMED to avoid a warning for callers in this module WARNING: Restricted methods will be blocked in a future release unless native access is enabled Apache Maven 3.6.3 (Red Hat 3.6.3-22) Maven home: /usr/share/maven Java version: 25.0.1, vendor: Red Hat, Inc., runtime: /usr/lib/jvm/java-25-openjdk Default locale: en_US, platform encoding: UTF-8 OS name: "linux", version: "5.14.0-503.31.1.el9_5.x86_64", arch: "amd64", family: "unix"
$ sudo apt-get install maven2 $ mvn -version Apache Maven 2.2.1 (rdebian-4) Java version: 1.6.0_22 Java home: /usr/lib/jvm/java-6-openjdk/jre Default locale: en_US, platform encoding: UTF-8 OS name: "linux" version: "2.6.38-8-generic" arch: "amd64" Family: "unix"
JAVA_HOME="/usr/lib/jvm/java-6-openjdk/jre" MAVEN_HOME="/usr/share/maven2/"
curl -s https://raw.githubusercontent.com/oscm/shell/master/lang/java/maven/maven.sh | bash
#!/bin/bash cd /usr/local/src/ wget https://mirrors.bfsu.edu.cn/apache/maven/maven-3/3.8.2/binaries/apache-maven-3.8.2-bin.tar.gz tar zxf apache-maven-3.8.2-bin.tar.gz mv apache-maven-3.8.2 /srv/ rm -f /srv/apache-maven ln -s /srv/apache-maven-3.8.2 /srv/apache-maven alternatives --install /usr/local/bin/mvn apache-maven-3.8.2 /srv/apache-maven-3.8.2/bin/mvn 0 mvn -v
apache-maven-3.8.2 配置
[root@localhost ~]# vim /srv/apache-maven/conf/settings.xml
<mirrors>
<!-- mirror
| Specifies a repository mirror site to use instead of a given repository. The repository that
| this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
| for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
|
<mirror>
<id>mirrorId</id>
<mirrorOf>repositoryId</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://my.repository.com/repo/path</url>
</mirror>
-->
<mirror>
<id>maven-default-http-blocker</id>
<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>
</mirror>
</mirrors>
apache-maven-3.8.2 默认会阻止其他镜像,需要会去掉 maven-default-http-blocker 配置
https://www.sonatype.com/nexus-repository-oss
https://github.com/sonatype/docker-nexus3
$ docker volume create --name nexus-data $ docker run -d -p 8081:8081 --name nexus -v nexus-data:/nexus-data sonatype/nexus3
#使用搜索工具去搜索maven包 % brew search maven #使用info查看maven包当前的信息情况,包括版本依赖描述等 % brew info maven # 安装 maven % brew install maven
备份 settings.xml 文件
neo@netkiller repository % ls /opt/homebrew/Cellar/maven/3.9.10/libexec/conf
logging settings.xml toolchains.xml
neo@netkiller repository % cd neo@netkiller repository % ls /opt/homebrew/Cellar/maven/3.9.10/libexec/conf
logging settings.xml toolchains.xml
neo@netkiller repository % cd /opt/homebrew/Cellar/maven/3.9.10/libexec/conf
neo@netkiller conf % cp settings.xml{,.backup}
neo@netkiller conf % ls
logging settings.xml settings.xml.backup toolchains.xml
cd /usr/local/src wget https://github.com/apache/maven-mvnd/releases/download/0.7.1/mvnd-0.7.1-linux-amd64.zip unzip mvnd-0.7.1-linux-amd64.zip mv mvnd-0.7.1-linux-amd64 /srv/mvnd-0.7.1 ln -s /srv/mvnd-0.7.1 /srv/mvnd alternatives --remove mvnd /usr/local/bin/mvnd alternatives --install /usr/local/bin/mvnd mvnd-0.7.1 /srv/mvnd-0.7.1/bin/mvnd 0
修改配置文件 mvnd.properties 制定 JAVA_HOME
[root@localhost cloud.netkiller.cn]# grep java.home /srv/mvnd/conf/mvnd.properties java.home=/usr/lib/jvm/java