Maven 권위 가이드 학습 노트 (1 - 8 장)

(1)  mavn       

1、       

mvn archetype:create -DgroupId=org.sonatype.mavenbook.ch03 -DartifactId=simple -DpackageName=org.sonatype.mavenbook

2、  mvn package        :(    , mavn       ,       )

	resources:resources \
	compiler:compile \
	resources:testResources \
	compiler:testCompile \
	surefire:test \
	jar:jar

3、maven    ( pom.xml    )

	<groupId>org.sonatype.mavenbook.ch03</groupId>
	<artifactId>simple</artifactId>
	<packaging>jar</packaging>
	<version>1.0-SNAPSHOT</version>

4、 eclipse  

	(1):     

	mvn eclipse:eclipse

       (2):          eclipse  ,      jar      (window  (C:\Documents and Settings\${username}\.m2\repository)
	
 	mvn eclipse:eclipse -DdownloadSources=true  
       
       (3):path-to-eclipse-workspace    eclipse worksapce   。   maven  eclipse     M2_REPO    ,       jar       ,     

	mvn -Declipse.workspace=<path-to-eclipse-workspace> eclipse:add-maven-repo

5、  main   

 mvn install
 mvn exec:java -Dexec.mainClass=org.sonatype.mavenbook.weather.Main

6、         

 mvn help:describe -Dplugin=exec -Dfull

7、      

 mvn dependency:resolve

8、             

 mvn dependency:tree

9、         

 mvn install -X

10、       

mvn test

11、                  

mvn test -Dmaven.test.failture.ignore=true

12、        

 mvn install -Dmaven.test.skip=true

13、Maven Assembly                     JAR      ,                    。

    :mvn install assembly:assembly

14、       jar      :

java -cp simple-weather-jar-width-dependency.jar org.sonatype.mavenbook.weather.Main

  :         ,   mvn install   ,  eclipse                。

(2)  web         

1、  web       :

mvn archetype:create -DgroupId=org.sonatype.mavenbook.ch05 -DartifactId=simple-webapp -DpackageName=org.sonatype.mavenbook.web -DarchetypeArtifactId=mavn-archetype-webapp

2、  Maven Jetty   ,  Maven       web  

mvn jetty:run

3、        

mvn clean install

(3)            

    

(1)                 
	
	               ,         。  ,      <relativePath>        pom.xml  。
	      jar    ,         ,              ,  groupId、version   。
	
	    
	
	simple-parent——————————simple—weather
			|
			———————simple-webapp
	
	        :
	1、simple-parent
	<modules>
		<module>simple-weather</module>
		<module>simple-webapp</module>
	</modules>
	2、simple—weather
	<!--         groupId version  ,             -->
	<parent>
		<groupId>org.sonatype.mavenbook</groupId>
		<artifactId>simple-parent</artifactId>
		<version>1.0</version>
	</parent>
	<artifactId>simple-weather</artifactId>
	<packaging>jar</packaging>
	<name>Simple-Weather</name>
	3、simple-webapp
	<!--         groupId version  ,              -->
	<parent>
		<groupId>org.sonatype.mavenbook</groupId>
		<artifactId>simple-parent</artifactId>
		<version>1.0</version>
	</parent>
	
	<artifactId>simple-webapp</artifactId>
	<packaging>war</packaging>
	
	<name>simple-webapp</name>
	<url>http://maven.apache.org</url>
	  simple-webapp   simple—weather,     <dependences>         
	<!--      weather  ,   weather         -->
	<dependency>
		<groupId>org.sonatype.mavenbook</groupId>
		<artifactId>simple-weather</artifactId>
		<version>1.0</version>
	</dependency>
	
	    
	
	|——simple-parent
	|——simple—weather
	|——simple-webapp

	        :

  	1、simple-parent
	<modules>
		<module>../simple-weather</module>
		<module>../simple-webapp</module>
	</modules>
	2、simple—weather
	<!--         groupId version  ,             -->
	<parent>
		<groupId>org.sonatype.mavenbook</groupId>
		<artifactId>simple-parent</artifactId>
		<version>1.0</version>
		<!--                simpe-parent  -->
		<relativePath>../simple-parent/pom.xml</relativePath>
	</parent>
	<artifactId>simple-weather</artifactId>
	<packaging>jar</packaging>
	<name>Simple-Weather</name>
	3、simple-webapp
	<!--         groupId version  ,              -->
	<parent>
		<groupId>org.sonatype.mavenbook</groupId>
		<artifactId>simple-parent</artifactId>
		<version>1.0</version>
		<!--                simpe-parent  -->
		<relativePath>../simple-parent/pom.xml</relativePath>
	</parent>
	
	<artifactId>simple-webapp</artifactId>
	<packaging>war</packaging>
	
	<name>simple-webapp</name>
	<url>http://maven.apache.org</url>
	  simple-webapp   simple—weather,     <dependences>         
	<!--      weather  ,   weather         -->
	<dependency>
		<groupId>org.sonatype.mavenbook</groupId>
		<artifactId>simple-weather</artifactId>
		<version>1.0</version>
	</dependency>
(4)          
1、           jar    parent pom.xml ,  properties        ,      jar ,       
	       :
	<properties>
    
		<hibernate.annotations.version>3.3.0.ga</hibernate.annotations.version>
    
		<hsqldb.version>1.8.0.7</hsqldb.version>
  
	</properties>
	<dependencyManagement>
		<dependencies>
			<dependency>
				<groupId>org.hibernate</groupId>
				<artifactId>hibernate-annotations</artifactId>
				<version>${hibernate.annotations.version}</version>
			</dependency>
			<dependency>
				<groupId>org.hibernate</groupId>
				<artifactId>hibernate-commons-annotations</artifactId>
				<version>${hibernate.annotations.version}</version>
			</dependency>
		<dependencies>
	<dependencyManagement>
	        :
	<dependencies>
		<dependency>
			<groupId>${project.groupId}</groupId>
			<artifactId>simple-model</artifactId>
			<version>${project.version}</version>
		</dependency>
		<dependency>
			<groupId>org.hibernate</groupId>
			<artifactId>hibernate</artifactId>
		</dependency>
		<dependency>
			<groupId>org.hibernate</groupId>
			<artifactId>hibernate-annotations</artifactId>
		</dependency>
		<dependency>
			<groupId>org.hibernate</groupId>
			<artifactId>hibernate-commons-annotations</artifactId>
		</dependency>
		<dependency>
			<groupId>org.apache.geronimo.specs</groupId>
			<artifactId>geronimo-jta_1.1_spec</artifactId>
			<version>1.1</version>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring</artifactId>
		</dependency>
	</dependencies>
2、          grouId version,

	<parent>
		<groupId>org.sonatype.mavenbook</groupId>
		<artifactId>simple-parent</artifactId>
		<version>1.0</version>
		<!--                simpe-parent -->
		<relativePath>../simple-parent/pom.xml</relativePath>
	</parent>

	<artifactId>simple-persist</artifactId>
	<packaging>jar</packaging>

	  ,                  :
	<dependency>
		<groupId>${project.groupId}</groupId>
		<artifactId>simple-model</artifactId>
		<version>${project.version}</version>
	</dependency>
3、  mvn dependency:analyze                      。

좋은 웹페이지 즐겨찾기