maven使用自己资料

maven.apache.org/guides/getting-started/index.html#What_is_Maven

新建JAVA普通项目:

mvn archetype:create \
  -DarchetypeGroupId=org.apache.maven.archetypes \
  -DgroupId=com.mycompany.app \
  -DartifactId=my-app

新建WTP web项目:

mvn archetype:create \
    -DarchetypeGroupId=org.apache.maven.archetypes \
    -DarchetypeArtifactId=maven-archetype-webapp \
    -DgroupId=com.mycompany.app \
    -DartifactId=my-webapp

下面是对pom.xml文件里面的标签进行讲解:

  • project This is the top-level element in all Maven pom.xml files.
  • modelVersion This element indicates what version of the object model this POM is using. The version of the model itself changes very infrequently but it is mandatory in order to ensure stability of use if and when the Maven developers deem it necessary to change the model.
  • groupId This element indicates the unique identifier of the organization or group that created the project. The groupId is one of the key identifiers of a project and is typically based on the fully qualified domain name of your organization. For example org.apache.maven.plugins is the designated groupId for all Maven plug-ins.
  • artifactId This element indicates the unique base name of the primary artifact being generated by this project. The primary artifact for a project is typically a JAR file. Secondary artifacts like source bundles also use the artifactId as part of their final name. A typical artifact produced by Maven would have the form <artifactid></artifactid>-<version></version>.<extension></extension> (for example, myapp-1.0.jar ).
  • packaging This element indicates the package type to be used by this artifact (e.g. JAR, WAR, EAR, etc.). This not only means if the artifact produced is JAR, WAR, or EAR but can also indicate a specific lifecycle to use as part of the build process. (The lifecycle is a topic we will deal with further on in the guide. For now, just keep in mind that the indicated packaging of a project can play a part in customizing the build lifecycle.) The default value for the packaging element is JAR so you do not have to specify this for most projects.
  • version This element indicates the version of the artifact generated by the project. Maven goes a long way to help you with version management and you will often see the SNAPSHOT designator in a version, which indicates that a project is in a state of development. We will discuss the use of snapshots and how they work further on in this guide.
  • name This element indicates the display name used for the project. This is often used in Maven's generated documentation.
  • url This element indicates where the project's site can be found. This is often used in Maven's generated documentation.
  • description This element provides a basic description of your project. This is often used in Maven's generated documentation.

    以下maven自已的命令格式:
    mvn compile

    mvn test

    mvn test-compile ( simply want to compile your test sources )

    mvn clean test-compile

    mvn install

    mvn clean install

    mvn clean  

  • mvn  install(可将你的项目打包成jar文件放到你的.m2/repo下面了)

     mvn package

  • mvn site

  • mvn resources:resources

  • mvn idea:idea

    mvn eclipse:eclipse  

    mvn eclipse:clean

    mvn process-resources

    mvn process-resources "-Dcommand.line.prop=hello again"
    

    # application.properties
    java.version=${java.version}
    command.line.prop=${command.line.prop}

  • # application.properties
    application.name=${pom.name}
    application.version=${pom.version}
      

    <build></build>
      <build></build>
        <resources></resources>
          <resource></resource>
            <directory></directory>src/main/resources
            <filtering></filtering>true
         
       
     


        
  • mvn deploy
    java 代码
    xml 代码
    1. [...]   
    2. <distributionManagement>  
    3. <repository>  
    4. <id>proficio-repositoryid>  
    5. <name>Proficio Repositoryname>  
    6. <url>file://${basedir}/target/deployurl>  
    7. repository>  
    8. distributionManagement>  
    9. [...]  


     指定编译后目录:

    xml 代码
    1. <build>  
    2.   <directory>${basedir}/targetdirectory>     
    3. build>  

     

  • For this example, we will configure the Java compiler to allow JDK 5.0 sources. This is as simple as adding this to your POM:

    ...
    <build></build>
      <plugins></plugins>
        <plugin></plugin>
          <groupid></groupid>org.apache.maven.plugins
          <artifactid></artifactid>maven-compiler-plugin
          <configuration></configuration>
            <source></source>1.5
            <target></target>1.5
         
       
     

    ...

    dependencies

    dependency这行依赖

  • http://www.devzuz.com/web/guest/downloads

  • 你可能感兴趣的:(apache,eclipse,maven,xml,idea)