MAVEN common commands + basic configuration details

mvn -v is similar to javac -version or git --version

using maven on linux also requires setting environment variables like using java this is
export M2_HOME = /?
export PATH = $PATH:$M2_HOME/bin
export MAVEN_OPTS = -Xms256m - Xmx512m


on the replacement of the embedded maven in myeclipse. The path is Windows-->Preferences-->Maven-->Click add on the right to replace



-------------------- ----------------General Common Commands----------------------------------------- ---------
mvn help:system Automatically create ~/.m2/repository under this user
mvn clean compile Clean and compile
mvn clean test Clean test
mvn clean package Clean package
mvn clean install Clean and save the packaged jar Enter the local warehouse Note that the local warehouse is
mvn archetype:generate Use Archetype to generate the project skeleton
mvn clean deploy Publish the project to the remote warehouse according to the configuration information in the pom
--------------------------Generally used commands----------- -----------------------------


--------------------- ------------maven directory structure----------------------------------- -----
src/main/java : Official content package path
src/mian/resources : Official configuration file path
src/test/java : Test package path
src/test/resources : Test configuration file path
src/main/ webapp : war resource directory
---------------------------------maven directory structure--------- -----------------------------------------



------------------- ---------Optimize dependency commands-------------------------------------- ---------
mvn dependency:list Displays all resolved dependencies
mvn dependency:tree Displays dependencies in the form of a directory tree, the highest level is a first-level dependency, a second-level dependency, and a third-level dependency....
mvn dependency:analyze The first part shows that the project is used but does not show the dependencies The second part shows that the project is not used but depends on
----------------------------Optimize Dependency Commands------------------- ----------------------------

Component: jar plugin war All dependent jar
builds: compile, test, package and release



------- --------------------About maven's life cycle and plug-in relationship -----------
Life The cycle is the interface: indicating what to do
Plug-in is the specific implementation: indicating how to do it
--------------------------------------- About maven Lifecycle and plugin relationships ---------------------



Aggregation, inheritance, integration testing, automated deployment, (these are very important to see for yourself)





The following is the common configuration of the pom.xml file


<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/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion> <!-- fixed value in MAVEN3-- >
  <groupId>cuiyaonan2000</groupId> <!-- the group it belongs to-->
  <artifactId>maven</artifactId> <!-- unique identifier-->
  <version>0.0.1-SNAPSHOT</version> < !-- Version number-->
  <packaging>war</packaging> <!-- The packaging method of the project, jar is used by default -->
  <name>Basic use of the maven project template</name>
  <description> The description here I don't know why it is used</description>
   
   <properties>
        <springframework.version>2.5.6</springframework.verson>
        <!-- The categorization dependency only needs to be used in <version>${springframework.version}</version> -->
   </properties>

<dependencies>
    <dependency>
          <groupId>junit</groupId>
          <artifactId>junit</artifactId>
          <version>4.7</version>
          <!-- <type>The type of dependency, not necessary in most cases The declaration defaults to jar</type> -->
          <scope>test</scope> <!-- Dependency scope For details on transitive dependencies, see p63 -->
          <!-- <optional>I don't understand whether the marked dependency is optional or not The values ​​are true and false. See p66 for details.</optional> -->
          <!--
                <exclusions>
                    <exclusion>
                        To exclude transitive dependencies, just list the following 2 items
                        <groupId></groupId>
                        <artifactId></artifactId>
                    </exclusion>
                </exclusions>
          -->
    </dependency>
</dependencies>




<build>
    <plugins>
        <!-- Set the corresponding java version of this plugin, it seems to solve a historical problem-->
        <plugin>
            <groupId>org.apache.maven .plugins</groupId>
          <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>1.5</source>
                <target>1.5</target>
            </configuration>
        </plugin>
        <!-- as follows Use UTF-8 to process resource files -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-resources-plugin</artifactId>
            <configuration>
                 <encoding>UTF-8</encoding>
            </configuration>
        </plugin>
    </plugins>


<!-- Configure the remote repository -->
<repositories>
    <!-- Setting the remote repository to directly receive the release version is not accepted Snapshot version -->
    <repository>
        <id>jboss</id> <!-- If central is used, it will overwrite the central repository -->
        <name>JBoss Repository</name>
        <url>http://repository. jboss.com/maven2/</url>
        <release>
            <enabled>true</enabled>
            <!-- The following 2 parameters are detailed on p83
            <updatePolicy>daily</updatePolicy>  
            <checksumPolicy>ignore</checksumPolicy>
            -->
        </release>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
        <layout>default</layout>
    </repository>
</repositories>



<!-- publish the project to the remote repository -->
<distributionManagement>
    <repository>
        < id>proj-release</id> <!-- The id here is to match the id of username and userpassword in setting.xml, some warehouses require a privileged account -->    
        <name>Proj Release Repository</name>
        <url>http://192.168.89.130</url>
    </repository>
    <snapshotRepository>
        <id>proj-release</id>
        <name>Proj Release Repository</name>
        <url>http://192.168. 89.130</url>
    </snapshotRepository>
</distributionManagement>

</build>
</project>


Guess you like

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