每次创建项目后都会有这几个文件,很多教程都直接说删掉
,也没介绍一下。
E:.
│ mvnw
│ mvnw.cmd
├─.mvn
│ └─wrapper
│ maven-wrapper.jar
│ maven-wrapper.properties
│ MavenWrapperDownloader.java
└─ 略...
其实这个mvnw
可以理解为一个当前项目特供的 mavn
mvnw
:linux 版脚本
mvnw.cmd
: windows 版脚本
maven
版本不同的来打包。我们也可以它来指定用特定的maven
版本进行打包。如果当前项目的Maven Wrapper
已经被我们删掉了,又或是其他原因,总之是没了。现在想挽回这段感情怎么办?安装之:
mvn wrapper:wrapper
Maven Wrapper
的版本到这里看:https://maven.apache.org/wrapper/download.cgi
用法也和maven
的 mvn
一样。只要把脚本换成mvnw
即可。
mvnw clean package
E:\demo>mvnw -v
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-11T00:41:47+08:00)
Maven home: C:\Users\jerry\.m2\wrapper\dists\apache-maven-3.3.9-bin\6d5080f4\apache-maven-3.3.9
Java version: 1.8.0_40, vendor: Oracle Corporation
Java home: D:\JDK8\jre
Default locale: zh_CN, platform encoding: GBK
OS name: "windows 8.1", version: "6.3", arch: "amd64", family: "dos"
mvn wrapper:wrapper -Dmaven=3.5.4
E:\demo>mvn wrapper:wrapper -Dmaven=3.5.4
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building fastjson2-demo 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-wrapper-plugin:3.1.1:wrapper (default-cli) @ fastjson2-demo ---
[WARNING] Archive entry '.mvn/wrapper/' and existing file 'E:\demo\fastjson2-demo\.mvn\wrapper' names differ only by case. This may lead to an unexpected outcome on case-insensitive filesystems.
[INFO] Unpacked bin type wrapper distribution org.apache.maven.wrapper:maven-wrapper-distribution:zip:bin:3.1.1
[INFO] Configuring .mvn/wrapper/maven-wrapper.properties to use Maven 3.5.4 and download from https://repo.maven.apache.org/maven2
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.500 s
[INFO] Finished at: 2022-09-17T11:48:38+08:00
[INFO] Final Memory: 12M/243M
[INFO] ------------------------------------------------------------------------
E:\demo>mvnw -v
Apache Maven 3.5.4 (1edded0938998edf8bf061f1ceb3cfdeccf443fe; 2018-06-18T02:33:14+08:00)
Maven home: C:\Users\jerry\.m2\wrapper\dists\apache-maven-3.5.4-bin\3b7e014\apache-maven-3.5.4
Java version: 1.8.0_40, vendor: Oracle Corporation, runtime: D:\JDK8\jre
Default locale: zh_CN, platform encoding: GBK
OS name: "windows 8.1", version: "6.3", arch: "amd64", family: "windows"
清理、打包
然后运行
:
mvnw clean package -Dmaven.test.skip=true && java -jar target\demo.jar