maven combat - 2

Chapter 3:
pom.xml configuration

namespace and elements of xsd
<?xml version="1.0" encoding="UTF-8"?>  
<project xmlns="http://maven.apache.org/POM/4.0.0"  
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">  


Indicate the version of the current pom model, for maven 2, 3, it can only be 4.0.0
<modelVersion>4.0.0</modelVersion>


Defines which group the project belongs to, usually the package name, import package name (this is the one)
<groupId>com.cxz</groupId>


Defines the unique ID of the current Maven item in the group, which is actually the package name of the file archive (without the version), for example:
maven-archetype-quickstart in maven-archetype-quickstart-1.1.jar
<artifactId>IntoRedis</artifactId>


Version
<version>1.0-SNAPSHOT</version>  


Configure the jdk version supported by the compiler
    <build>  
        <plugins>  
            <plugin>  
                <groupId>org.apache.maven.plugins</groupId>  
                <artifactId>maven-compiler-plugin</artifactId>  
                <version>2.3.2</version>  
                <configuration>  
                    <source>1.7</source>  
                    <target>1.7</target>  
                </configuration>  
            </plugin>  
        </plugins>  
    </build>


mvn clean package usually packaged jar can not be run directly, you can use maven-shade-plugin, configure the plugin as follows
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-shade-plugin </artifactId>
  <version>1.2.1</version>
  <executions>
    <execution>
      <phase>package</phase>
      <goals>
         <goal>shade</goal>
      </goals>
     <configuration>
       <transformers>
         < transformer
            implementation="
             org.apache.maven.plugins.shade.resource.MainfestResourceTransformer">
             <mainClass>com.juvenxu.mvnbook. helloworld.HelloWorld</mainClass>
         </transformer>
       </transformers>
     </configuration>
   </execution>
  </executions>
</plugin>


Role: import the corresponding package through this code
<dependencies>   
        <dependency>  
            <groupId>org.apache.hadoop</groupId>  
            <artifactId>hadoop-common</artifactId>  
            <version>2.0.0-cdh4.2.1</version>  
            <type>jar</type>  
            <exclusions>  
                <exclusion>  
                    <artifactId>kfs</artifactId>  
                    <groupId>net.sf.kosmosfs</groupId>  
                </exclusion>  
            </exclusions>  
            <scope>provided</scope>  
        </dependency>  
    </dependencies>  


The scope of dependencies is when to import this package
<scope>provided</scope>


maven common commands

   maven common commands
   mvn -version
   mvn compile
   mvn test
   mvn clean compile
   mvn clean package
   mvn clean install


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326312354&siteId=291194637