- surefire-plugin is for running unit test, if any test fail it will fail the build immediately
- surefire-plugin can use <testFailureIgnore>true</testFailureIgnore> to run all test
- failsafe-plugin is for running integration test, it will run all tests and fail at verify stage
- surefire-plugin use "mvn test" and failsafe-plugin use "mvn verify"
2. mvn eclipse:eclipse (obsolete)
- this command will read pom.xml and generate metadata for eclipse
- run 'mvn eclipse:eclipse' to update eclipse project, then refresh project
- afterwards you can use eclipse 'import existing project' to import a maven project
- this command is no longer needed with latest version of eclipse, where you can import 'exisitng maven project'
3. add oracle jdbc driver to maven
- due to oracle license restriction, there is NO public maven repository provides oracle jdbc driver
- you have to install it manually into your maven local repository
4. groupid, artifactid, version, packaging
- groupid is domain name, e.g. com.example.foo
- artifactid is name of artifact (jar or war or other executable file)
- when no packaging is declared, maven assume default is 'jar'
5. standard alone maven and maven in eclipse
- they will use same repo in ~/.m2 folder, if artifact is download by one, it will not be downloaded by the other
- if seeing 'could not calculate build plan: Plugin org.apache.maven.plugins:maven-resources-plugin:2.5 or one of its dependencies could not be resolved' error, run 'mvn compile', if it works, it's maven setting issue in eclipse
6. settings.xml
- global settings: ${maven.home}/conf/settings.xml
- user settings: ${user.home}/.m2/settings.xml
- by default user settings is not created
- if both exist, a merge of global and user will be used by standalone maven
- in both m2eclipse plugin and intellij maven plugin, user can specify the setting to use
7. dependency vs. module
- dependency is library need to build the project
- module means when you build main project, sub module project will be built too
8. project lombok
- reduce boilerplate code for model/data object
- generate getter/setter automatically by adding annotations
9. parent tag in pom.xml
- maven read parent pom content and concatenate with current pom
10. access maven command line argument from java class
- -Dexec.args
- you can use System.getProperty("exec.args") to get any environment variable set on command line with the flag -D
- define an 'action'
- has 'groupId', 'artifactId' and 'version'
12. intellij
- intellij has maven plugin bundled by default
- in run/debug configuration, can set maven command line parameter
- maven option on the right hand side of intellij
- open settings.xml in intellij by right click in the pom.xml file -> maven -> open 'settings.xml'
- note that brew install maven's settings.xml location is different from default intellij' settings.xml location (~/.m2/settings.xml)
- sometimes after mvn clean install, it is still showing package missing, and in 'project structure -> project settings -> modules', the dependency modules are missing too. then you can click the refresh button in maven tab to 'reimport all maven projects'
13. mvn -v //show maven home details
reference
1. eclipse and maven via command line
2. how to add oracle jdbc driver in your maven local repository
3. could-not-calculate-build-plan-plugin-org-apache-maven-pluginsmaven-resources
4. configure-external-maven-to-run-within-eclipse
5. what is maven-settings-xml
6. install 3rd party jar in maven in windows
7. introduction to project lombok
8. how to access maven arguments from java class?
2. how to add oracle jdbc driver in your maven local repository
3. could-not-calculate-build-plan-plugin-org-apache-maven-pluginsmaven-resources
4. configure-external-maven-to-run-within-eclipse
5. what is maven-settings-xml
6. install 3rd party jar in maven in windows
7. introduction to project lombok
8. how to access maven arguments from java class?