Maven Wrapper 的作用是什么
mvnw 是 Maven Wrapper 的缩写。即每次编译启动 spring boot 的那个命令:
./mvnw spring-boot:run
Maven Wrapper 的作用是在 spring boot 项目中指定 maven 版本。以统一项目组成员使用一致的 maven 版本。可以参考 maven-wrapper.properties 文件的存储内容。
maven-wrapper.properties 文件存储了什么
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar
.mvn/wrapper/maven-wrapper.properties does not exist
git clone 下来的 spring boot 项目,在 build 时报错:
./mvnw spring-boot:run
Exception in thread "main" java.lang.RuntimeException: Wrapper properties file '/mnt/d/work/calf/.mvn/wrapper/maven-wrapper.properties' does not exist.
at org.apache.maven.wrapper.WrapperExecutor.forWrapperPropertiesFile(WrapperExecutor.java:54)
at org.apache.maven.wrapper.MavenWrapperMain.main(MavenWrapperMain.java:60)
确认 maven 是否安装
> mvn --version
Command 'mvn' not found, but can be installed with:
sudo apt install maven
安装提示 apt install 之后,确认是否安装成功
> mvn --version
Apache Maven 3.6.0
Maven home: /usr/share/maven
Java version: 1.8.0_275, vendor: Private Build, runtime: /usr/lib/jvm/java-8-openjdk-amd64/jre
Default locale: en, platform encoding: UTF-8
OS name: "linux", version: "4.4.0-18362-microsoft", arch: "amd64", family: "unix"
但是安装之后,报错依旧。
git status 发现的问题
> git status
On branch master
Your branch is up to date with 'origin/master'.
Changes not staged for commit:
(use "git add/rm <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
deleted: .mvn/wrapper/maven-wrapper.properties
no changes added to commit (use "git add" and/or "git commit -a")
zhongwei@HOME /m/d/w/calf> git checkout -- .mvn/wrapper/maven-wrapper.properties
确实是被误删了。。。恢复即可。
但是重新执行 ./mvnw spring-boot:run 要耐心等待,要很长时间才有响应。
微信关注我哦 👍
我是来自山东烟台的一名开发者,有感兴趣的话题,或者软件开发需求,欢迎加微信 zhongwei 聊聊, 查看更多联系方式