- 下载解压
要注意版本问题,idea2018.02版本支持3.5.2版本maven,高版本不支持,会报错:Unable to import maven project: See logs for details
可参考README.txt
JDK:
1.7 or above (this is to execute Maven - it still allows you to build against 1.3
and prior JDK's).
- 环境变量配置
Path 添加:%MAVEN_HOME%\bin
- 修改bin/mvn.cmd添加JAVA_HOME,这样cmd里面就能执行mvn命令了
@setlocal
set "JAVA_HOME=D:\dev\dev-lib\jdk-11.0.10+9"
set "MAVEN_OPTS=-Xms128m -Xmx1024m -XX:MaxPermSize=512m -XX:ReservedCodeCacheSize=64m"set ERROR_CODE=0
@REM ==== START VALIDATION ====
- 修改conf-/setting.xml文件
3.修改中央仓库。默认在国外, 国内使用很慢,我这里用阿里的中央仓库,也可以用网易的,或者Apache的。
同时配置默认中央仓库,当阿里镜像缺少jar包是,自动从中央仓库下载。
修改conf-/setting.xml文件
<mirrors>
<!-- 阿里云仓库 -->
<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
<!-- 中央仓库1 -->
<mirror>
<id>repo1</id>
<mirrorOf>central</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://repo1.maven.org/maven2/</url>
</mirror>
<!-- 中央仓库2 -->
<mirror>
<id>repo2</id>
<mirrorOf>central</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://repo2.maven.org/maven2/</url>
</mirror>
</mirrors>
4. 配置默认JDK版本
4.1.全局配置:修改maven安装目录下的settings.xml文件,profiles标签添加:
<profile>
<id>jdk-1.8</id>
<activation>
<activeByDefault>true</activeByDefault>
<jdk>1.8</jdk>
</activation>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
</properties>
</profile>
4.2.项目级配置:在项目中的pom.xml指定jdk版本 - 只保证当前项目
---jdk11:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<release>11</release>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
</build>
---jdk8:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
</build>
5.idea配置为刚刚下载的maven
6.Updating indexes是Maven在下载更新,这个需要手动去设置即可:
Window --> Preferences --> Maven --> 去除Download repository index updates on startup前的勾选,然后重启软件。
7.对于oralce的jdbc驱动,虽然能在maven仓库里搜索到,但貌似不能用,原因是oracle是要收费的,不能通过远程的方式来引入,只能通过配置本地库来加载到工程里
mvn install:install-file -DgroupId=com.oracle -DartifactId=ojdbc8 -Dversion=12.2.0.1 -Dpackaging=jar -Dfile=D:\now\ojdbc8.jar