JDK安装
http://blog.csdn.net/fenglailea/article/details/26006647
环境变量设置
http://blog.csdn.net/fenglailea/article/details/52457731
风.fox
YUM 临时代理
命令行中先执行如下命令,然后再执行yum xxx命令
export http_proxy="http://10.1.5.50:9999"
http://10.1.5.50:9999 :代理服务器IP和端口
Maven
Apache Maven是一个软件项目管理和综合工具。基于项目对象模型(POM)的概念,Maven可以从一个中心资料片管理项目构建,报告和文件。
本教程将介绍如何使用Maven在Java开发,或任何其他的编程语言的任何项目。
http://www.yiibai.com/maven/
Maven 安装
编译后代码安装
下载地址:http://maven.apache.org/download.cgi
选择 Binary tar.gz archive
wget http://mirrors.tuna.tsinghua.edu.cn/apache/maven/maven-3/3.6.1/binaries/apache-maven-3.6.1-bin.tar.gz
tar zxvf apache-maven-3.6.1-bin.tar.gz
mkdir -p /usr/java/
mv apache-maven-3.6.1 /usr/java/
设置环境变量文件
vim /etc/profile.d/maven.sh
设置环境变量
#!/bin/bash
export MAVEN_HOME=/usr/java/apache-maven-3.6.1
export M2_HOME=$MAVEN_HOME
export PATH=$MAVEN_HOME/bin:$PATH
应用生效
source /etc/profile
source /etc/bashrc
yum repo安装
wget http://repos.fedorapeople.org/repos/dchen/apache-maven/epel-apache-maven.repo -O /etc/yum.repos.d/epel-apache-maven.repo
yum -y install apache-maven
如果手动安装过JAVA ,使用下面更新Maven 中的JAVA版本
alternatives --config java
alternatives --config javac
maven的java文件编译后会保存在target目录下
查看Maven版本
mvn -v
Maven 更改国内镜像设置【推荐】
找到 maven目录
vim /usr/java/apache-maven-3.5.4/conf/settings.xml
找到mirrors,修改或增加如下
<mirrors>
<mirror>
<id>ali maven</id>
<name>aliyun maven</name>
<url>https://maven.aliyun.com/repository/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
这个时候就可以享受飞速下载了
来自
http://blog.csdn.net/u010717403/article/details/52188496
https://blog.cospotato.tech/2017/02/03/阿里云Maven镜像使用的正确姿势/
配置多个仓库
vim /usr/java/apache-maven-3.5.4/conf/settings.xml
增加或修改内容
<mirrors>
<mirror>
<id>ali maven</id>
<name>aliyun maven</name>
<url>https://maven.aliyun.com/repository/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
<mirror>
<id>ui</id>
<mirrorOf>central</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://uk.maven.org/maven2/</url>
</mirror>
<mirror>
<id>ibiblio</id>
<mirrorOf>central</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://mirrors.ibiblio.org/pub/mirrors/maven2/</url>
</mirror>
<mirror>
<id>jboss-public-repository-group</id>
<mirrorOf>central</mirrorOf>
<name>JBoss Public Repository Group</name>
<url>http://repository.jboss.org/nexus/content/groups/public</url>
</mirror>
<!--访问慢的网址放入到后面-->
<mirror>
<id>CN</id>
<name>OSChina Central</name>
<url>http://maven.oschina.net/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
<mirror>
<id>net-cn</id>
<mirrorOf>central</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://maven.net.cn/content/groups/public/</url>
</mirror>
<mirror>
<id>JBossJBPM</id>
<mirrorOf>central</mirrorOf>
<name>JBossJBPM Repository</name>
<url>https://repository.jboss.org/nexus/content/repositories/releases/</url>
</mirror>
</mirrors>
来自
https://blog.csdn.net/www1056481167/article/details/60139851?utm_source=blogxgwz0
mirrorOf 说明
1.<mirrorOf>*</mirrorOf>
匹配所有远程仓库。
2.<mirrorOf>external:*</mirrorOf>
匹配所有远程仓库,使用localhost的除外,使用file://协议的除外。也就是说,匹配所有不在本机上的远程仓库。
3.<mirrorOf>repo1,repo2</mirrorOf>
匹配仓库repo1和repo2,使用逗号分隔多个远程仓库。
4.<mirrorOf>*,!repo1</miiroOf>
匹配所有远程仓库,repo1除外,使用感叹号将仓库从匹配中排除。
5.<mirrorOf>central</miiroOf>
值为central
, 表示该配置为中央仓库的镜像
https://blog.csdn.net/caomiao2006/article/details/40401517
Maven的settings.xml文件结构之activeProfiles
无论是在pom.xml
文件中,还是在settings.xml
文件中,都可以配置多个<profile>
。但是并非所有的<profile>
都会被激活,即该<profile>
的配置生效与否,可以通过如下方式进行控制:
- 在
pom.xml
文件中通过<profile>
的<activation>
- 在
settings.xml
文件中通过<profile>
的<activation>
- 在
settings.xml
文件中通过<activeProfiles>
其中,通过<profile>
的<activation>
配置激活对应的<profile>
条件,这个在pom.xml文件中和在settings.xml
文件中是一致的,详见pom.xml
文件的配置。
在settings.xml
文件中,还可以通过<activeProfiles>
直接给出被激活的<profile>
(可以有多个),示例如下:
<activeProfiles>
<activeProfile>dev</activeProfile>
</activeProfiles>
在上述示例中,默认激活<id>dev</id>
的<profile>
。当然,也可以根据需要,默认激活多个<profile>
。
来自
https://blog.csdn.net/taiyangdao/article/details/52311257
配置pom.xml 的 dev Maven 仓库
<profiles>
<profile>
<id>dev</id>
<repositories>
<repository>
<id>nexus</id>
<url>https://maven.aliyun.com/repository/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>nexus</id>
<url>https://maven.aliyun.com/repository/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
来自 https://blog.csdn.net/yaoyuncn/article/details/52996240
Maven 自动发布更新本地和远程仓库
编译源码时同时更新本地仓库
mvn clean package install
或(跳过测试)
mvn clean package install -Dmaven.test.skip=true
编译源码时同时更新远程仓库
mvn clean package deploy
或(跳过测试)
mvn clean package deploy -Dmaven.test.skip=true
Maven 某些错误
[WARNING] The POM for com.alibaba:dubbo:jar:2.8.4 is missing, no dependency information available
…
[ERROR] Failed to execute goal on project dubbo-monitor: Could not resolve dependencies for project com.handu.open:dubbo-monitor:war:1.0.0: Failure to find com.alibaba:dubbo:jar:2.8.4 in http://maven.aliyun.com/nexus/content/groups/public/ was cached in the local repository, resolution will not be reattempted until the update interval of alimaven has elapsed or updates are forced -> [Help 1]
以上的错误原因就是本地Maven仓库缺少某些包。
类似以上的错误都可以用这种方法解决
这个是我在本地编译 dubbox-monitor监控端(http://git.oschina.net/handu/dubbo-monitor)所报的错误。
解决方法
1.先把 dubbox(https://github.com/dangdangdotcom/dubbox)下载下来,
解压缩后,进入dubbox目录,
重新用如下命令编译一次
mvn clean package install -Dmaven.test.skip=true
2.然后进入我要编译的 dubbox-monitor监控端(http://git.oschina.net/handu/dubbo-monitor)目录
执行
mvn clean package -Dmaven.test.skip=true
这时你就会发现,编译通过了,不用再找烦人的错误了
Maven 代理设置
最简单方法:
直接在后面加上 IP地址和端口
-DsocksProxyHost=127.0.0.1 -DsocksProxyPort=8888
例如要编译 某个东西
mvn clean install -Dmaven.test.skip=true -DsocksProxyHost=127.0.0.1 -DsocksProxyPort=8888
SOCKS5
<proxy>
<id>my-proxy</id>
<active>true</active>
<protocol>socks5</protocol>
<username></username>
<password></password>
<host>127.0.0.1</host>
<port>8888</port>
<nonProxyHosts>127.0.0.1</nonProxyHosts>
</proxy>
http代理
<proxies>
<proxy>
<id>my-proxy</id>
<active>true</active>
<protocol>http</protocol>
<host>127.0.0.1</host>
<port>8888</port>
<username>有就填写没有就删除</username>
<password>有就填写没有就删除</password>
<nonProxyHosts>127.0.0.1|*.lanmps.com</nonProxyHosts>
</proxy>
</proxies>
ANT
yum -y install ant