maven一些命令

1. 查看依赖包树

mvn dependency:tree -Dverbose

2. maven通过命令修改版本号
mvn versions:set -DnewVersion=1.0.1.0.0-SNAPSHOT
mvn versions:commit
或者
mvn versions:set -DnewVersion=1.0.1.0.0-SNAPSHOT -DgenerateBackupPoms=false

编译: mvn compile

打包: mvn package
清除缓存文件: mvn clean
安装到本地仓库: mvn install
3 跳过测试模块
-Dmaven.test.skip=true

4 添加打包插件, 并指定主方法启动类

<build>
<sourceDirectory>src/main/java</sourceDirectory>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.2.8.RELEASE</version>
<configuration>
<mainClass>com.example.TestSftp</mainClass>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
5 指定字符编码和jdk版本

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.encoding>UTF-8</maven.compiler.encoding>
<java.version>11</java.version>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
6 maven跳过证书下载包 mvn clean install -Dmaven.test.skip=true -Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true -Dmaven.wagon.http.ssl.ignore.validity.dates=true -U

7. 打包编译时会排除掉某些文件

<build>

   <resources>

       <resource>

          <directory>src/main/resources</directory>

          <excludes>

              <exclude>**/client.keystore.jks</exclude>

              <exclude>**/client.truststore.jks</exclude>

              <exclude>**/common.properties</exclude>

              <exclude>**/srvkfkbdpsit.keytab</exclude>

              <exclude>**/log4j2.xml</exclude>

          </excludes>

          <filtering>false</filtering>

     </resource>

   </resources>

</build>

8. 测试同一台服务器启动多个进程

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix></classpathPrefix>
<mainClass>com.aexpec.bdp.parser.flinkx.Main</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugins>
<build>

入口类

public class Main{

    public static void main(String[] args) throws Exception {

   ...

 

    }

}

run.bat文件

@echo off

chcp 65001

cd /d %~dp0

echo "running now.."

java -jar ./AutoMoveMouse-1.0.jar

echo "running end.."

pause

新建多个.bat文件,同时启动,就会产生多个进程

 

posted @ 2022-07-11 10:53  剑阁丶神灯  阅读(99)  评论(0编辑  收藏  举报