What is the purpose of mvnw and mvnw.cmd files?

前端 未结 4 1917
余生分开走
余生分开走 2020-12-12 08:50

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?

4条回答
  •  离开以前
    2020-12-12 09:07

    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 the mvnw.cmd is for the Windows environment.


    To create or update all necessary Maven Wrapper files execute the following command:

    mvn -N io.takari:maven:wrapper
    

    To use a different version of maven you can specify the version as follows:

    mvn -N io.takari:maven:wrapper -Dmaven=3.3.3
    

    Both commands require maven on PATH (add the path to maven bin to Path on System Variables) if you already have mvnw in your project you can use ./mvnw instead of mvn in the commands.

提交回复
热议问题