Unix base 环境变量设置
总是对linux及mac下环境变量设置不熟悉,故把maven的环境配置贴到博客做个备忘
Unix-based Operating Systems (Linux, Solaris and Mac OS X)
- Extract the distribution archive, i.e.
apache-maven-3.0.3-bin.tar.gzto the directory you wish to install Maven 3.0.3. These instructions assume you chose/usr/local/apache-maven. The subdirectoryapache-maven-3.0.3will be created from the archive. - In a command terminal, add the
M2_HOMEenvironment variable, e.g.export M2_HOME=/usr/local/apache-maven/apache-maven-3.0.3. - Add the
M2environment variable, e.g.export M2=$M2_HOME/bin. - Optional: Add the
MAVEN_OPTSenvironment variable to specify JVM properties, e.g.export MAVEN_OPTS="-Xms256m -Xmx512m". This environment variable can be used to supply extra options to Maven. - Add
M2environment variable to your path, e.g.export PATH=$M2:$PATH. - Make sure that
JAVA_HOMEis set to the location of your JDK, e.g.export JAVA_HOME=/usr/java/jdk1.5.0_02and that$JAVA_HOME/binis in yourPATHenvironment variable. - Run
mvn --versionto verify that it is correctly installed.
这里的配置是在命令行里的设置,要想永久生效,还得设置到环境变量文件中。已mac os 设置maven为例
打开 /etc/profile
在最后加入
M2_HOME=/Users/sindtom/java/soft/maven/apache-maven-3.0.4
M2=$M2_HOME/bin
MAVEN_OPTS="-Xms64m -Xmx128m -Dfile.encoding=UTF-8"
PATH=$M2:$PATH
这时候就前面就不要在加 export 指令了