🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
环境变量配置M2_HOME MAVEN_OPTS : -Xms128m -Xmx512m -Duser.language=zh -Dfile.encoding=UTF-8 这个可配置可不配置 **修改setting.xml** ~~~ <?xml version="1.0" encoding="UTF-8"?> <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"> <pluginGroups /> <proxies /> <servers /> <localRepository>D:/server/maven/repository</localRepository> <mirrors> <mirror> <id>alimaven</id> <mirrorOf>central</mirrorOf> <name>aliyun maven</name> <url>http://maven.aliyun.com/nexus/content/repositories/central/</url> </mirror> <mirror> <id>alimaven</id> <name>aliyun maven</name> <url>http://maven.aliyun.com/nexus/content/groups/public/</url> <mirrorOf>central</mirrorOf> </mirror> <mirror> <id>central</id> <name>Maven Repository Switchboard</name> <url>http://repo1.maven.org/maven2/</url> <mirrorOf>central</mirrorOf> </mirror> <mirror> <id>repo2</id> <mirrorOf>central</mirrorOf> <name>Human Readable Name for this Mirror.</name> <url>http://repo2.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>google-maven-central</id> <name>Google Maven Central</name> <url>https://maven-central.storage.googleapis.com </url> <mirrorOf>central</mirrorOf> </mirror> <!-- 中央仓库在中国的镜像 --> <mirror> <id>maven.net.cn</id> <name>oneof the central mirrors in china</name> <url>http://maven.net.cn/content/groups/public/</url> <mirrorOf>central</mirrorOf> </mirror> </mirrors> </settings> ~~~ **IntellIJ IDEA 中配置Maven** Idea 自带了apache maven,默认使用的是内置maven,所以我们可以配置全局setting,来调整一下配置,比如远程仓库地址,本地编译环境变量等。 ![](https://box.kancloud.cn/2e66bdeb14b4e3a70244a982cb43b145_1356x1224.png) ![](https://box.kancloud.cn/4cf54f8abdd4caed377bfb8383b74420_2376x1000.png) ![](https://box.kancloud.cn/dec34f4baf14fe87a028fd9ce67a578c_1822x880.png) ![](https://box.kancloud.cn/d67c3844b5af6035501cd1d66ab239cf_1432x1100.png) **创建maven工程** ![](https://box.kancloud.cn/71a3b2e1f375c2c4d87c22038a45df99_618x527.png) ![](https://box.kancloud.cn/8cc0e8ed553a9354eabf570dfa239da4_542x522.png) 这个参数的意义是让这个maven项目的骨架不要到远程下载而是本地获取。如果你没加这个参数,那么项目创建可能在卡在downloading maven plugins...继续点击Next ![](https://box.kancloud.cn/083d5f162885fef465566848d35fac66_896x337.png) ![](https://box.kancloud.cn/d7bf6534c5c8e20db76ec65542d8b53a_405x767.png) ![](https://box.kancloud.cn/cfc6bc1afadc5ba613431e82bf01a087_869x450.png) **设置artifact** ![](https://box.kancloud.cn/6620c900f919de01200617b152b2840f_842x389.png) **如果你电脑配置比较高,可以把idea的配置调高** ![](https://box.kancloud.cn/f514804609dad8b6d3760c53d9c8b569_720x936.png) ![](https://box.kancloud.cn/18732bc27b380d7199ec7396b50a7aa8_467x350.png) 让idea响应速度提升 **使用IntelliJ IDEA 通过maven插件运行tomcat7** 在pom.xml文件中添加如下依赖 <build> <finalName>test_setting</finalName> <plugins> <plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat7-maven-plugin</artifactId> <configuration> <port>8080</port> <path>/</path> </configuration> </plugin> </plugins> </build> **配置编译版本** 由于是Maven没指定编译版本引起的,所以先在pom.xml指定编译版本,添加如下内容指定编译版本(一般情况下版本和所用jdk版本保持一致,如我这里是1.8): ~~~ <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.1</version> <configuration> <source>1.8</source> <target>1.8</target> </configuration> </plugin> </plugins> </build> ~~~ 或者 ~~~ <properties> <maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.target>1.8</maven.compiler.target> </properties> ~~~ **Maven指定的编译版本生效** http://blog.csdn.net/gnail_oug/article/details/77507614 **maven的debug** http://blog.csdn.net/CronousGT/article/details/79384105