February 6, 2015 11:34
Apache Maven is a software project management and comprehension tool. Based on the concept of a project object model(POM), Maven can manage a project's build, reporting and documentation from a central piece of information.
maven 英音 /'meɪv(ə)n/ 美音 /ˈmevən/ an expert in a particular subject
Apache Maven 3.2.5 February 6, 2015 09:56
Maven is a Java tool, so you must have Java installed in order to proceed.
configurate at ~/.m2
3 levels configuration:
The location of you local repository can be changed in you user configuration. The default vlue is ~/.m2/repository
<settings>
...
<localRepository>/path/to/local/repo/</localRepository>
...
</settings>
mvn archetype:generate -DgroupId=com.csst.app -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
my-app
|-- pom.xml
`-- src
|-- main
| `-- java
| `-- com
| `-- mycompany
| `-- app
| `-- App.java
`-- test
`-- java
`-- com
`-- mycompany
`-- app
`-- AppTest.java
1 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3 <modelVersion>4.0.0</modelVersion>
4 <groupId>com.csst.app</groupId>
5 <artifactId>my-app</artifactId>
6 <packaging>jar</packaging>
7 <version>1.0-SNAPSHOT</version>
8 <name>my-app</name>
9 <url>http://maven.apache.org</url>
10 <dependencies>
11 <dependency>
12 <groupId>junit</groupId>
13 <artifactId>junit</artifactId>
14 <version>3.8.1</version>
15 <scope>test</scope>
16 </dependency>
17 </dependencies>
18 </project>
mvn archetype:generate: prefix archetype is the plugin
parameter -DgroupId=com.csst.app:
<groupId>com.csst.app</groupId>
parameter -DartifactId=my-app:
<artifactId>my-app</artifactId>
parameter -DarchetypeArtifactId=maven-archetype-quickstart
-DinteractiveMode=false
mvn package
xugg@xuggs-MacBook-Air ~/P/m/my-app> mvn package
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building my-app 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ my-app ---
[WARNING] Using platform encoding (US-ASCII actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /Users/xugg/Project/mvn/my-app/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ my-app ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ my-app ---
[WARNING] Using platform encoding (US-ASCII actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /Users/xugg/Project/mvn/my-app/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ my-app ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ my-app ---
[INFO] Surefire report directory: /Users/xugg/Project/mvn/my-app/target/surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running com.csst.app.AppTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.005 sec
Results :
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ my-app ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.352 s
[INFO] Finished at: 2015-02-06T12:59:52+08:00
[INFO] Final Memory: 9M/118M
[INFO] ------------------------------------------------------------------------
xugg@xuggs-MacBook-Air ~/P/m/my-app>
java -cp target/my-app-1.0-SNAPSHOT.jar com.csst.app.App
java -cp classpath class
deploy: done in an integration or release environment, copies the final package to the remote repository for sharing with other developers and projects.
clean: cleans up artifacts crated by prior builds
site: generates site documentation for this project.
$ mvn archetype:generate -DgroupId={project-packaging}
-DartifactId={project-name}
-DarchetypeArtifactId=maven-archetype-webapp
-DinteractiveMode=false
//for example
$ mvn archetype:generate -DgroupId=com.csst -DartifactId=mybatis_test -DarchetypeArtifactId=maven-archetype-webapp -DinteractiveMode=false
[INFO] Generating project in Batch mode
too long for wating. adding parameter:
-DarchetypeCatalog=internal
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.2.2</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.22</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.5</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
<scope>runtime</scope>
</dependency>
mvn compile
mvn eclipse:eclipse -Dwtpversion=2.0
Description Resource Path Location Type The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path index.jsp /mybatis_test/src/main/webapp line 1 JSP Problem