maven test 运行 指定类或方法 打包 mvn clean assembly:assembly

>mvn test -Dtest=[ClassName]
运行测试类中指定的方法:(这个需要maven-surefire-plugin:2.7.3以上版本才能支持)
 
>mvn test -Dtest=[ClassName]#[MethodName]
//[MethodName]为要运行的方法名,支持*通配符,范例:
>mvn test -Dtest=MyClassTest#test1
>mvn test -Dtest=MyClassTest#*test*
 
 
 mvn clean assembly:assembly 生产jar包,在target文件夹下面,在pom.xml中添加下面的插件
可用 java -jar target/xxx.jar main函数参数列表的形式 运行jar包
复制代码
<build>
  <plugins>
  <plugin>
    <artifactId>maven-assembly-plugin</artifactId>
    <configuration>
      <finalName>打包后生成的jar包的名字</finalName>
      <appendAssemblyId>false</appendAssemblyId>
      <descriptorRefs>
        <descriptorRef>jar-with-dependencies</descriptorRef>
      </descriptorRefs>
      <archive>
        <manifest>
          <mainClass>jar包的入口,也就是想要调用的main函数所在的包</mainClass>
        </manifest>
      </archive>
    </configuration>
    <executions>
      <execution>
        <phase>package</phase>
        <goals>
          <goal>single</goal>
        </goals>
      </execution>
    </executions>
  </plugin>
  </plugins>
  </build>
复制代码
原文地址:https://www.cnblogs.com/exmyth/p/12510402.html