and command maven maven plugin

1, commonly used commands

  1. Display version information: mvn -version

  2. Create a project: mvn archetype: generate

  3. The project idea into a project: mvn idea: idea

  4. Compile the source code is compiled into Java byte code class files: mvn compile

  The tests and test report generation: mvn test

  6. The old class bytecode files compiled from previously deleted: mvn clean

  7. packaged, dynamic web project to fight the war package, Java jar packaging project: mvn package (the default is jar package)

    Before performing the packaging commands, it will automatically execute mvn compile, mvn test command, it is recommended to use package command mvn clean package, to clean it before packaging class files

    Just playing war package (web project): mvn war: war

    Playing only jar package: mvn jar: jar, so labeled jar package can not run, labeled jar package can run to add Maven plugin, you can add <plugin> tag in pom.xml file, use the maven-jar-plugin and plug-maven-dependency-plugin package

    <build>  
        <plugins>  
      
            <plugin>  
                <groupId>org.apache.maven.plugins</groupId>  
                <artifactId>maven-jar-plugin</artifactId>  
                <version>2.6</version>  
                <configuration>  
                    <archive>  
                        <manifest>  
                            <addClasspath>true</addClasspath>  
                            <classpathPrefix>lib/</classpathPrefix>  
                 <!-- 这里设置主类,即程序的入口--> <mainClass>com.wqc.main.SpringStart</mainClass> </manifest> </archive> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <version>2.10</version> <executions> <execution> <id>copy-dependencies</id> <phase>package</phase> <goals> <goal>copy-dependencies</goal> </goals> <configuration> <outputDirectory>${project.build.directory}/lib</outputDirectory> </configuration> </execution> </executions> </plugin> </plugins> </build>

Labeled jar package in the target directory, using java -jar xxx.jar run the jar package

 

  Item 8. The jar packets generated on the local repository, to call other modules, the local installation: mvn install

    When executed mvn install command automatically executed before mvn compile, mvn test, mvn package command, it is recommended to use mvn clean install command to clean up the old class file, execute jar install will be generated on the local warehouse,

    That is the default local repository C:. \ Users \ admin (user directory) \ m2 \ repository

  9. Build the project-related information website: mvn site

  10. Compile content test: mvn test-compile

  11. deployment project: mvn deploy

Reference: https://www.cnblogs.com/best/p/9676515.html

Guess you like

Origin www.cnblogs.com/yjh1995/p/11896716.html