Maven仓库镜像修改---阿里或网易
网易: http://mirrors.163.com/.help/maven.html
一、通过修改setting.xml修改maven
打开maven配置文件
./apache-maven-3.5.2/conf/settings.xml
找到<mirrors></mirrors>标签节点
添加一个的mirror子节点:
<mirror> <id>nexus-163</id> <mirrorOf>*</mirrorOf> <name>Nexus 163</name> <url>http://mirrors.163.com/maven/repository/maven-public/</url> </mirror>
二、在maven项目pom中使用
打开项目配置文件
pom.xml 添加或修改 <repositories> <repository> <id>nexus-163</id> <name>Nexus 163</name> <url>http://mirrors.163.com/maven/repository/maven-public/</url> <layout>default</layout> <snapshots> <enabled>false</enabled> </snapshots> <releases> <enabled>true</enabled> </releases> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>nexus-163</id> <name>Nexus 163</name> <url>http://mirrors.163.com/maven/repository/maven-public/</url> <snapshots> <enabled>false</enabled> </snapshots> <releases> <enabled>true</enabled> </releases> </pluginRepository> </pluginRepositories>
执行maven update更新一下即可。
二 maven.plugins配置
<properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <hadoop.version>2.7.3</hadoop.version> <java.version>1.8</java.version> <maven.version.min>3.2.5</maven.version.min> <scala.minor.version>2.11</scala.minor.version> <scala.complete.version>${scala.minor.version}.8</scala.complete.version> <spark.version>2.0.1</spark.version> <corenlp.version>3.4.1</corenlp.version> </properties>
<pluginManagement> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-enforcer-plugin</artifactId> <version>1.4.1</version> <executions> <execution> <id>enforce</id> <configuration> <rules> <requireModuleConvergence/> <requireMavenVersion> <version>${maven.version.min}</version> </requireMavenVersion> <requireJavaVersion> <version>${java.version}</version> </requireJavaVersion> </rules> </configuration> <goals> <goal>enforce</goal> </goals> </execution> <execution> <id>default-cli</id> <goals> <goal>enforce</goal> </goals> <phase>validate</phase> <configuration> <rules> <requireJavaVersion> <message> <![CDATA[You are running an older version of Java. This application requires at least JDK ${java.version}.]]> </message> <version>[${java.version}.0,)</version> </requireJavaVersion> </rules> </configuration> </execution> </executions> </plugin> <plugin> <groupId>org.apache.rat</groupId> <artifactId>apache-rat-plugin</artifactId> <version>0.12</version> <configuration> <excludes> <exclude>**/*.iml</exclude> <exclude>**/*.md</exclude> <exclude>**/*.txt</exclude> <exclude>**/*.geojson</exclude> <exclude>**/target/**</exclude> <exclude>**/dependency-reduced-pom.xml</exclude> <exclude>.travis.yml</exclude> </excludes> <licenses> <license implementation="org.apache.rat.analysis.license.SimplePatternBasedLicense"> <patterns> <pattern>Copyright 2015 and onwards Sanford Ryza, Juliet Hougland, Uri Laserson, Sean Owen and Joshua Wills </pattern> </patterns> </license> </licenses> </configuration> <executions> <execution> <phase>verify</phase> <goals> <goal>check</goal> </goals> </execution> </executions> </plugin> <plugin> <groupId>net.alchim31.maven</groupId> <artifactId>scala-maven-plugin</artifactId> <version>3.2.2</version> <configuration> <scalaVersion>${scala.complete.version}</scalaVersion> <scalaCompatVersion>${scala.minor.version}</scalaCompatVersion> <args> <arg>-unchecked</arg> <arg>-deprecation</arg> <arg>-feature</arg> </args> <javacArgs> <javacArg>-source</javacArg> <javacArg>${java.version}</javacArg> <javacArg>-target</javacArg> <javacArg>${java.version}</javacArg> </javacArgs> </configuration> <executions> <execution> <phase>compile</phase> <goals> <goal>compile</goal> </goals> </execution> </executions> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.5.1</version> <configuration> <skip>true</skip> <!-- scala plugin compiles everything --> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.18.1</version> <configuration> <useFile>false</useFile> <disableXmlReport>true</disableXmlReport> <includes> <include>**/*Test.*</include> <include>**/*Suite.*</include> </includes> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-clean-plugin</artifactId> <version>3.0.0</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-source-plugin</artifactId> <version>3.0.1</version> <executions> <execution> <id>attach-sources</id> <goals> <goal>jar</goal> </goals> </execution> </executions> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <version>3.0.2</version> <configuration> <skipIfEmpty>true</skipIfEmpty> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-assembly-plugin</artifactId> <version>2.6</version> <configuration> <descriptorRefs> <descriptorRef>jar-with-dependencies</descriptorRef> </descriptorRefs> <recompressZippedFiles>false</recompressZippedFiles> </configuration> <executions> <execution> <phase>package</phase> <goals> <goal>single</goal> </goals> </execution> </executions> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-install-plugin</artifactId> <version>2.5.2</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId> <version>3.0.1</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-deploy-plugin</artifactId> <version>2.8.2</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <version>2.10</version> <executions> <execution> <id>copy-dependencies</id> <phase>package</phase> <goals> <goal>copy-dependencies</goal> </goals> <configuration> <includeScope>runtime</includeScope> </configuration> </execution> </executions> </plugin> </plugins> </pluginManagement>