Maven commonly used commands:
Maven repository:
http://repo2.maven.org/maven2/
Maven relies query:
A, Maven commonly used commands:
1. Create a plain Java Maven project:
mvn archetype:create -DgroupId=packageName -DartifactId=projectName
2. Create a Web project Maven:
mvn archetype:create -DgroupId=packageName -DartifactId=webappName -DarchetypeArtifactId=maven-archetype-webapp
3. Reverse maven project generating skeleton:
mvn archetype:generate
? How do you create your maven project is not like this:
mvn archetype:create -DarchetypeArtifactId=maven-archetype-quickstart -DgroupId=com.ryanote -Dartifact=common
If you then, then you're out, and with all the modern mvn archetype: generate, and this project will create more humane boring thing, you no longer need to remember so many of archetypeArtifactId, you just enter the archetype: generate, the rest is done "choice" of.
Abbreviations writing:
mvn archetype:generate -DgroupId=otowa.user.dao -DartifactId=user-dao -Dversion=0.01-SNAPSHOT
4. Compile the source code:
mvn compile
5. Compile the test code:
mvn test-compile
6. Run the test:
mvn test
7. generate site:
mvn site
8. Packaging:
mvn package
9. The jar is mounted in the Local Repository:
mvn install 例:installing D:\xxx\xx.jar to D:\xx\xxxx
10. Clear generated by the project:
mvn clean
11. generate eclipse project:
mvn eclipse:eclipse
12. Generate project idea:
mvn idea:idea
13. The combination of commands goal, not only as packaging test:
mvn -Dtest package
14. Compile content of the test:
mvn test-compile
15. The only jar packaging:
mvn jar:jar
16. The test only without the compiler does not compile test:
Test Test -skipping the compile -skipping mvn-the compile (-skipping flexible use, of course, also be used in other combinations command)
17. Some systems purge eclipse settings:
mvn eclipse:clean
18. View the current project has been resolved dependency:
mvn dependency:list
19. Upload to PW:
mvn deploy
20. The mandatory check for updates, because the snapshot version of the update strategy (updated several times a day, once every other period of time to update) exist, if you want to force an update will use this command:
mvn clean install-U
21. Source Package:
mvn source:jar 或 mvn source:jar-no-fork
Difference mvn compile with mvn install, mvn deploy the
- mvn compile, compiled class files
- mvn install, contains mvn compile, mvn package, then upload it to a local warehouse
- mvn deploy, contains mvn install, then upload it to PW
Two, PS:
Generally used is the case, first code via cvs or svn downloaded to the machine, and then execute mvn eclipse: eclipse generating ecllipse project file, and then introduced into eclipse on the line; performed after modifying the code mvn compile or mvn test inspection, can download eclipse the maven plugin.
1. Display version information:
mvn -version/-v
2. Create mvn project:
mvn archetype:create -DgroupId=com.oreilly -DartifactId=my-app
3. Generate target directory, compile, test code, generate test reports, generated jar / war file:
mvn package
4. Run the project on the jetty:
mvn jetty:run
The display detailed error message:
mvn -e
6. Verify that the project is correct and that all required resources are available:
mvn validate
7. Handling and publish packages in integrated test environment can run in:
mvn integration-test
8. Run any checks to verify whether the packet is valid and to meet quality standards:
mvn verify
9. any additional source code application needs, such as xdoclet:
mvn generate-sources
10. Use the help of plug-ins to describe the target output Maven Help plugin:
mvn help:describe -Dplugin=help
11. Use Help complete plugin output targets with parameters column:
mvn help:describe -Dplugin=help -Dfull
12. Obtain information for a single destination, setting parameters and mojo plugin parameters. This command lists all the information compile goal of the Compiler plugin:
mvn help:describe -Dplugin=compiler -Dmojo=compile -Dfull
13. All Maven Exec lists the target plug-ins are available:
mvn help:describe -Dplugin=exec -Dfull
14. Look at this, "valid (effective)" POM, it exposes Maven's default settings:
mvn help:effective-pom
15. For a complete dependence trail, including those components because of a conflict or other reasons be rejected introduced to open the Debug mark of running Maven:
mvn install -X
16. Add maven.test.skip property to any goal you can skip the test:
mvn install -Dmaven.test.skip=true
17. Construction of assembly Maven Assembly Plugin is a plug-in to create your application-specific bundles:
mvn install assembly:assembly
18. Plug-generated Wtp Web project:
mvn -Dwtpversion=1.0 eclipse:eclipse
19. Clear the configuration information Eclipse Project (Web project):
mvn -Dwtpversion=1.0 eclipse:clean
20. The project into Eclipse projects:
mvn eclipse:eclipse
21. mvn exec commands can be executed in the project main functions:
Mvn compile: first need to compile java project in the absence of parameters: mvn exec: java -Dexec.mainClass = " . *** Main" exist parameters: mvn exec: java -Dexec.mainClass = " . *** Main" -Dexec.args = "arg0 arg1 arg2" specifies the runtime library: mvn exec: java -Dexec.mainClass = " . *** Main" -Dexec.classpathScope = runtime
22. Print out a list of resolved dependencies:
mvn dependency:resolve
23. Print the entire dependency tree:
mvn dependency:tree
In applications using multiple repositories
<repositories> <repository> <id>Ibiblio</id> <name>Ibiblio</name> <url>http://www.ibiblio.org/maven/</url> </repository> <repository> <id>PlanetMirror</id> <name>Planet Mirror</name> <url>http://public.planetmirror.com/pub/maven/</url> </repository> </repositories> mvn deploy:deploy-file -DgroupId=com -DartifactId=client -Dversion=0.1.0 -Dpackaging=jar -Dfile=d:\client-0.1.0.jar -DrepositoryId=maven-repository-inner -Durl=ftp://xxxxxxx/opt/maven/repository/
Jar to publish third-party local library
mvn install:install-file -DgroupId=com -DartifactId=client -Dversion=0.1.0 -Dpackaging=jar -Dfile=d:\client-0.1.0.jar -DdownloadSources=true -DdownloadJavadocs=true
Third, additional
mvn help:describe
Because if you can not remember what a plugin goal and painful too, because if you can not remember what parameters have a goal and distress, then try this command it, it will tell you everything.
Parameters: 1. -Dplugin = pluginName 2. -Dgoal (or -Dmojo) = goalName: used with -Dplugin, it lists information about a plug-in goal,
If you find it is not detailed enough, can also be added -Ddetail (Note: a plugin goal is also considered a "Mojo").
Here everyone would run mvn help: describe -Dplugin = help -Dmojo = describe feelings about it!
mvn tomcat:run
After using maven, you'll never need to run a web project (practical work often find use it without synchronization update will appear) in the eclipse with tomcat, in the corresponding directory just run mvn tomat: run the command, then you can run in the browser view that if you want more customization, can be configured in the pom.xml file in Riga following:
01 02 03 04 org.codehaus.mojo 05 tomcat-maven-plugin 06 07 / web 08 9090 09 10 11 12 Of course, you can also order Riga parameters to achieve specific functions,
Here are several commonly used:
1> to skip the test: -Dmaven.test.skip (= true)
2> designated port:. -Dmaven.tomcat.port = 9090
3> ignore test failed:. -Dmaven.test.failure.ignore = true, of course, if you have had other associated project updates, be sure to run mvn clean install in the project root directory to perform the update, and then run mvn tomcat: run for the changes to take effect.
mvnDebug tomcat:run
This command is mainly used for remote testing, it listens on port 8000 of remote testing, remote testing in the open after the eclipse, it will run up, set breakpoints, debug, everything is so simple. Mentioned above several parameters that apply equally here.
mvn dependency:sources
Name suggests, with it, you do not have to find that source, and run the source code in your project depends on the package have a jar
Maven repository:
http://repo2.maven.org/maven2/
Maven relies query:
A, Maven commonly used commands:
1. Create a plain Java Maven project:
mvn archetype:create -DgroupId=packageName -DartifactId=projectName
2. Create a Web project Maven:
mvn archetype:create -DgroupId=packageName -DartifactId=webappName -DarchetypeArtifactId=maven-archetype-webapp
3. Reverse maven project generating skeleton:
mvn archetype:generate
? How do you create your maven project is not like this:
mvn archetype:create -DarchetypeArtifactId=maven-archetype-quickstart -DgroupId=com.ryanote -Dartifact=common
If you then, then you're out, and with all the modern mvn archetype: generate, and this project will create more humane boring thing, you no longer need to remember so many of archetypeArtifactId, you just enter the archetype: generate, the rest is done "choice" of.