maven

maven
1.配置环境变量path
MAVEN_HOME(或M2_HOME) PATH: “;%MAVEN_HOME%\bin”
检测:echo %MAVEN_HOME% 或者 mvn –version (需要JDK)
2.“仓库”,坐标:aritifact group
3.常用命令
创建 项目的骨架 mvn archetype:generate
编译项目 mvn clean compile
单元测试 mvn clean test
项目打包 mvn clean package
mvn archetype:generate -DgroupId=com.lianggzone.core -DartifactId=maven_prime2 -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
mvn archetype:generate -DgroupId=com.lianggzone.core -DartifactId=maven_prime2 -DarchetypeArtifactId=maven-archetype-webapp -DinteractiveMode=false
-DgroupId  #包名
-DartifactId #项目名称
-DarchetypeArtifactId #指定ArchetypeId,maven-archetype-quickstart,创建一个Java Project;maven-archetype-webapp,创建一个Web Project
-DinteractiveMode #是否使用交互模式
将本地jar包,导入本地仓库 打开jar存在的文件夹
cd D:\lang
mvn install:install-file -DgroupId=commons-lang -DartifactId=commons-lang -Dversion=3-3.1 -Dpackaging=jar -Dfile=commons-lang3-3.1.jar

4.idea创建maven项目时:
archetypeCatalog=internal

5.maven-compiler-plugin

<plugins>
    <!--
        指定maven插件编译版本
        1:maven:since2.0, 默认用jdk1.3来编译,maven 3.x 貌似是默认用jdk 1.5。 
        2:windows默认使用GBK编码,java项目经常编码为utf8,也需要在compiler插件中指出,否则中文乱码可能会出现编译错误。 
     -->
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <!-- since 2.0 -->
        <version>3.7.0</version>
        <configuration>
            <!-- use the Java 8 language features -->
            <source>1.8</source>
            <!-- want the compiled classes to be compatible with JVM 1.8 -->
            <target>1.8</target>
            <!-- The -encoding argument for the Java compiler. -->
            <encoding>UTF8</encoding>
        </configuration>
    </plugin>
</plugins>

6.maven-surefire-plugin

2. <plugin>  
  3.                 <groupId>org.apache.maven.plugins</groupId>  
  4.                 <artifactId>maven-surefire-plugin</artifactId>  
  5.                 <version>2.19</version>  
  6.                 <configuration>  
  7.                     <skip>true</skip>  
  8.                     <testFailureIgnore>true</testFailureIgnore>  
  9.                     <includes>  
  10.                         <include>**/*Test.java</include>  
  11.                         <include>**/*TestCase.java</include>  
  12.                         <include>**/Test*.java</include>  
  13.                     </includes>  
  14.                     <excludes>  
  15.                         <exclude>**/Abstract*.java</exclude>  
  16.                     </excludes>  
  17.                 </configuration>  
  18.             </plugin>

7.maven-war-plugin

   <!-- war打包插件 -->  
  33.             <plugin>  
  34.                 <groupId>org.apache.maven.plugins</groupId>  
  35.                 <artifactId>maven-war-plugin</artifactId>  
  36.                 <version>2.2</version>  
  37.                 <configuration>  
  38.                     <!-- http://maven.apache.org/plugins/maven-war-plugin/ -->  
  39.                     <packagingExcludes>WEB-INF/web.xml</packagingExcludes>  
  40.                 </configuration>  
  41.             </plugin>  
  42.         </plugins>

下面一份maven的demo:

<?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>  
            <name>aliyun maven</name>  
            <url>http://maven.aliyun.com/nexus/content/groups/public/</url>  
            <mirrorOf>central</mirrorOf>  
        </mirror>  
    </mirrors>  
  <profiles>  
    <profile>  
       <id>nexus</id>   
        <repositories>  
            <repository>  
                <id>nexus</id>  
                <name>local private nexus</name>  
                <url>http://maven.oschina.net/content/groups/public/</url>  
                <releases>  
                    <enabled>true</enabled>  
                </releases>  
                <snapshots>  
                    <enabled>false</enabled>  
                </snapshots>  
            </repository>  
        </repositories>  

        <pluginRepositories>  
            <pluginRepository>  
            <id>nexus</id>  
            <name>local private nexus</name>  
            <url>http://maven.oschina.net/content/groups/public/</url>  
            <releases>  
                <enabled>true</enabled>  
            </releases>  
            <snapshots>  
                <enabled>false</enabled>  
            </snapshots>  
            </pluginRepository>  
        </pluginRepositories>  
    </profile></profiles>  

</settings>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值