-
Maven installation
Download address: https://maven.apache.org/download.cgiUnzip
to the working directory
Configure environment variables: MAVEN_HOME, path
verification: cmd–> mvn -v
-
Maven project structure and creation method
First-level directory src is the source code directory
Second-level directory main / java is the main code directory of the project
Second-level directory resource directory, yaml file
Second-level directory test / java is the project test code directory, unit test, test code, etc.
First-level directory:
pom.xml file – the maven configuration file that depends on the configuration of the plug-in and other configurations; the project object description file, the properties and method configuration of the project object.
Exercise for creating Maven project:
GroupId: company domain name reverse
Artifactid: project name -
Maven configuration file Settings.xml
modify the location of the local warehouse: D: \ Program Files (x86) \ apache-maven-3.5.2-bin \ apache-maven-3.5.2 \ repository
configuration warehouse:
alimaven
aliyun maven
http: // maven.aliyun.com/nexus/content/groups/public/
central
Idea configuration maven: settings–> Maven–> Maven home directory, user settings file -
Analysis of project object file pom.xml
-
Common commands
mvn clean 清理项目生产的临时文件,一般是模块下的target目录
mvn package 项目打包工具,会在模块下的target目录生成jar或war等文件
mvn test 测试命令,或执行src/test/java/下Junit的测试用例
mvn install 模块安装命令,将打包的jar/war文件复制到你的本地仓库中,供其他模块使用
mvn install -DskipTests 绕过单元测试直接打包。
mvn deploy 发布命令,丽江打包的文件发布到远程仓库,提供其他人员进行下载依赖,一般是发布到公司的私服。