`
liuzongan
  • 浏览: 92969 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

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

  • 分享到:
    评论

    相关推荐

      maven使用文档,maven使用文档

      ### Maven 使用文档详解 #### Maven 简介与特点 Maven 是一款强大的项目管理和构建工具,主要用于 Java 项目的管理。Maven 提供了统一的标准流程来管理项目的生命周期、依赖关系以及项目信息等,极大地提高了开发...

      使用Maven导入Maven工程的视频教程

      使用Maven导入Maven工程的视频教程 仅供学习交流! 后续会持续分享相关资源,记得关注哦! 使用Maven导入Maven工程的视频教程 使用Maven导入Maven工程的视频教程 使用Maven导入Maven工程的视频教程 使用Maven导入...

      Maven资料大合集

      通过这份Maven资料大合集,你将能够全面了解Maven的工作原理,熟练掌握Maven的使用技巧,并能在实际项目中运用自如。无论你是想要快速入门,还是提升Maven使用水平,这套资料都能提供宝贵的指导。

      idea+maven使用教程

      **Idea + Maven 使用教程** ...本教程提供的 "Maven简介及安装.pdf" 和 "安装IDEA.pdf" 文档,将详细介绍上述内容,对于初学者来说是很好的参考资料。通过学习,你将能够熟练地在 Idea 中使用 Maven 进行开发工作。

      maven学习相关资料

      该资料主要讲maven的基础用法,安装和使用等。还有maven常常被使用到的一些命令和用法。注意事项等。

      Maven笔记与资料.zip

      Maven使用一种称为POM(Project Object Model)的XML文件来描述项目,并自动解决依赖关系,使得开发人员可以专注于编写代码,而不是处理库的版本管理和构建脚本。 ** Maven的POM ** POM,即项目对象模型,是Maven...

      maven学习资料 maven学习资料 maven学习资料 maven学习资料

      maven学习资料

      maven学习的基础资料

      【Maven学习的基础资料】 Maven是一个强大的项目管理和综合工具,主要面向Java开发人员。它通过提供一个标准的项目生命周期框架,大大简化了项目的构建、文档生成、依赖管理、源码分布等任务。Maven的核心理念是...

      maven教案-maven入门学习资料

      2. **依赖管理**:Maven 使用中央仓库管理所有项目的依赖关系,项目只需要在 POM 文件中声明所需依赖,Maven 就会自动下载并管理这些依赖,解决了jar包的重复拷贝和版本冲突问题。 【 Maven 构建方式的比较】 - **...

      maven中文学习资料

      maven中文学习,maven-definitive-guide_zh.pdf

      Maven资料

      ** Maven资料概述 ** Maven是一个强大的Java项目管理和构建工具,由Apache软件基金会开发。它通过提供一个标准化的构建过程,使得项目的构建、依赖管理以及文档生成变得简单易行。Maven通过使用一种名为POM...

    Global site tag (gtag.js) - Google Analytics