创建MAVEN工程

如何合并(人工复制-修改了同一个( 覆盖)? 版本控制

Maven

创建工程

  • 工程结构(规范工程结构)
  • 导包(在工程下创建libs--从网站下载jar -复制到libs ---手动的添加到工程)

安装

  • 去官网下载maven
  • 解压

配置

修改/xxx/config/settings.xml

  1. 修改本地库路径

    <localRepository>你自己的路径\repository</localRepository>
    
  2. 修改成阿里云仓库

    <mirror>  
         <!-- 仓库id-->
         <id>alimaven</id>  
         <name>aliyun maven</name>  
         <url>http://maven.aliyun.com/nexus/content/groups/public/</url>  
         <mirrorOf>central</mirrorOf>
       <!-- 可选 -->
     <repository>        
     </mirror>
    
  3. 修改命令创建工程默认的jdk版本(可选)

    <profiles>
    <profile>    
         <id>jdk-1.8</id>    
          <activation>    
               <activeByDefault>true</activeByDefault>    
               <jdk>1.8</jdk>    
            </activation>    
      <properties>    
        <maven.compiler.source>1.8</maven.compiler.source>    
        <maven.compiler.target>1.8</maven.compiler.target>    
        <maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>    
     </properties>    
    </profile>
    </profiles>
    

idea集成

  • idea本身自己集成了maven
  • 配置自定义的maven

创建maven工程

工程结构

pom文件

    <!--    模型版本号  不要动-->
    <modelVersion>4.0.0</modelVersion>
    <!--    -->
    <groupId>com.mvn</groupId>
    <artifactId>maven-demo</artifactId>
    <!--     外包项目  -->
    <!--  迭代开发  -->
    <!--  版本迭代是  三位数   -->
    <!--
        1  大版本更新 重大的革新 +1
        2  新的功能
        3  修复小bug
       -->
    <version>1.3.3-SNAPSHOT</version>
    <!--    传统的web项目部署的时候打包方式  zip-->
    <!--    可选值  3
           传统web项目  默认是 war
           spring boot 工程中 默认是jar  jar不是给项目依赖的 而是直接可以运行的
           pom   继承的时候使用
      -->
    <packaging>war</packaging>
    <name>maven-demo Maven Webapp</name>
    <url>http://www.example.com</url>
    <!--    通过管理版本号   -->
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <spring.version>5.2.7.RELEASE</spring.version>
        <mysql.version>8.0.20</mysql.version>
        <druid.version>1.1.22</druid.version>
    </properties>
    <!--  统计  -->
    <dependencies>
        <!--        <dependency>-->
        <!--            <groupId>org.springframework</groupId>-->
        <!--            <artifactId>spring-core</artifactId>-->
        <!--            <version>${spring.version}</version>-->
        <!--            &lt;!&ndash;            一般情况下不需要去设置&ndash;&gt;-->
        <!--            <type>jar</type>-->
        <!--            &lt;!&ndash;            作用域&ndash;&gt;-->
        <!--            <scope>compile</scope>-->
        <!--            &lt;!&ndash; pom &ndash;&gt;-->
        <!--        </dependency>-->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>${spring.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework</groupId>
                    <artifactId>spring-core</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.11</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>druid</artifactId>
            <version>${druid.version}</version>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>${mysql.version}</version>
            <!--             false  子项目必须依赖-->
            <!--            true   表示不依赖-->
            <!--            <optional>false</optional>-->
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>4.0.1</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>
</project>

如何导入maven 工程

maven的生命周期

常用操作

  • clean
  • compile
  • package
  • test
  • install
  • deploy
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。