美文网首页
maven常用命令

maven常用命令

作者: 小李_a98e | 来源:发表于2018-08-07 11:14 被阅读0次

    maven常用指令

    • 打包跳过测试

    -DskipTests
    
    • idea maven控制台乱码

    Maven -> Runner 增加JVM参数 -Dfile.encoding=GB2312
    
    • 指定maven编译插件

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.3</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <encoding>UTF-8</encoding>
                    <compilerArguments>
                        <extdirs>lib</extdirs>
                    </compilerArguments>
                </configuration>
            </plugin>
    
    • 清洁本地仓库

    mvn dependency:purge-local-repository
    
    • 添加时间戳

    <properties>
        <maven.build.timestamp.format>
            yyyy-MM-dd'T'HH:mm:ss'Z'
        </maven.build.timestamp.format>
    </properties>
    
    • 回显属性

        <plugin>
           <groupId>org.apache.maven.plugins</groupId>
           <artifactId>maven-antrun-plugin</artifactId>
           <version>1.1</version>
           <executions>
               <execution>
                   <phase>validate</phase>
                   <goals>
                       <goal>run</goal>
                   </goals>
                   <configuration>
                       <tasks>
                           <echo>
                                settings.localRepository = ${settings.localRepository}
                           </echo>
                           <echo>
                                project.build.directory = ${project.build.directory}
                           </echo>
                       </tasks>
                   </configuration>
               </execution>
           </executions>
      </plugin>
    
    • 配置阿里云镜像

        <mirror>
          <id>alimaven</id>
          <name>aliyun maven</name>
          <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
          <mirrorOf>central</mirrorOf>        
        </mirror>
    
    • jar包打入本地仓库

    mvn install:install-file -Dfile=E:/jar/xx.jar -DgroupId=xxx 
     -DartifactId=xx -Dversion=1.0 -Dpackaging=jar 
    
    • maven 打包插件

        <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>1.4</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <transformers>
                                <transformer
                                        implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                    <resource>META-INF/spring.handlers</resource>
                                </transformer>
                                <transformer
                                        implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                    <mainClass>主类</mainClass>
                                </transformer>
                                <transformer
                                        implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                    <resource>META-INF/spring.schemas</resource>
                                </transformer>
                            </transformers>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
    

    相关文章

      网友评论

          本文标题:maven常用命令

          本文链接:https://www.haomeiwen.com/subject/bayovftx.html