When I created a Spring Boot application I could see mvnw
and mvnw.cmd
files in the root of the project. What is the purpose of these two files?
相关问题
- Dependency injection into Logback Appenders with S
- Deserialize duplicate keys to list using Jackson
- Include pom.xml in Jar with gradle
- How can I access the repository from the entity in
- Prevent Swagger from automatically adding some mod
相关文章
- IDEA2020 安装maven 插件后,springboot程序 SpringBootApplic
- pom文件中的插件定义
- pom.xml中的project为何报红
- Hibernate Tutorial - Where to put Mapping File?
- How to load @Configuration classes from separate J
- Using Spring Dynamic Languages Support from Groovy
- Spring JMS : Set ErrorHandler for @JmsListener ann
- Cannot use org.jvnet.jax-ws-commons.jaxws-maven-pl
Command
mvnw
uses Maven that is by default downloaded to~/.m2/wrapper
on the first use.URL with Maven is specified in each project at
.mvn/wrapper/maven-wrapper.properties
:To update or change Maven version invoke the following (remember about
--non-recursive
for multi-module projects):or just modify
.mvn/wrapper/maven-wrapper.properties
manually.To generate wrapper from scratch using Maven (you need to have it already in
PATH
run:By far the best option nowadays would be using a maven container as a builder tool. A
mvn.sh
script like this would be enough:The Maven Wrapper is an excellent choice for projects that need a specific version of Maven (or for users that don't want to install Maven at all). Instead of installing many versions of it in the operating system, we can just use the project-specific wrapper script.
mvnw: it's an executable Unix shell script used in place of a fully installed Maven
mvnw.cmd: it's for Windows environment
Use Cases
The wrapper should work with different operating systems such as:
After that, we can run our goals like this for the Unix system:
And the following command for Batch:
If we don't have the specified Maven in the wrapper properties, it'll be downloaded and installed in the folder
$USER_HOME/.m2/wrapper/dists
of the system.Maven Wrapper plugin
Maven Wrapper plugin to make auto installation in a simple Spring Boot project.
First, we need to go in the main folder of the project and run this command:
We can also specify the version of Maven:
The option -N means –non-recursive so that the wrapper will only be applied to the main project of the current directory, not in any submodules.
These files are from Maven wrapper. It works similarly to the Gradle wrapper.
This allows you to run the Maven project without having Maven installed and present on the path. It downloads the correct Maven version if it's not found (as far as I know by default in your user home directory).
The
mvnw
file is for Linux (bash) and themvnw.cmd
is for the Windows environment.To create or update all necessary Maven Wrapper files execute the following command:
To use a different version of maven you can specify the version as follows:
Both commands require maven on
PATH
(add the path to mavenbin
toPath
on System Variables) if you already have mvnw in your project you can use./mvnw
instead ofmvn
in the commands.