zoukankan      html  css  js  c++  java
  • Maven技术 基础

    一、配置基本信息

    1. 装maven解压到一个目录下,在eclipse中配置解压好的目录

    2. 配置settings.xml文件:

     

    3. settings.xml中需要配置的内容:

    <!-- 本地仓库地址 -->
    <localRepository>E:/apache-maven-3.3.3/repository</localRepository>
         
    <!-- 阿里云镜像,比国外的下载快 -->
     <mirror>
            <id>alimaven</id>
            <name>aliyun maven</name>
            <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
            <mirrorOf>central</mirrorOf>
     </mirror>
    <!-- 配置JDK版本 -->
    <profile>
                <id>jdk-10</id>
                <activation>
                    <activeByDefault>true</activeByDefault>
                    <jdk>10</jdk>
                </activation>
                <properties>
                    <maven.compiler.source>10</maven.compiler.source>
                    <maven.compiler.target>10</maven.compiler.target>
                    <maven.compiler.compilerVersion>10</maven.compiler.compilerVersion>
                </properties>
        </profile>
        

    二、创建maven项目

    1. pom.xml配置文件中配置依赖的项目或jar包

    例:配置spring-webmvc  jar包:可以在https://mvnrepository.com/ 中查找groupId , artifactId , version 

      <dependencies>
          <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>4.3.9.RELEASE</version>
        </dependency>
      </dependencies>
      

    例:配置所依赖的项目

         <dependencies>
              <dependency>
                  <groupId>com.caijava</groupId>
                  <artifactId>maven1</artifactId>
                  <version>0.0.1-SNAPSHOT</version>
              </dependency>
          </dependencies>

    2. 创建pom项目(父项目)

    properties 标签的子标签是自定义的,定义之后可以用${ names }来获取值

    dependencyManagement 标签声明可能要用到的jar包,需要在子项目中配置groupId 和 artifactId 才能使用,不用配置version ,该标签可以起到管理jar 包版本的作用

      <properties>
          <spring-version>4.3.9.RELEASE</spring-version>
      </properties>
      <dependencyManagement>
          <dependencies>
              <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>${spring-version}</version>
            </dependency>
      </dependencies>

    3.创建子项目:

    <dependencies>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-webmvc</artifactId>
            </dependency>
        </dependencies>

     三、创建web项目:

     

  • 相关阅读:
    postman调试参数格式
    Dapper.Contrib.Extensions扩展
    kafka dashborad 安装流程(kafka_exporter + prometheus + grafana)
    Kafka学习入门(windows环境下)
    Windows环境下载安装Kafka
    Windows环境下Zookeeper的安装及启动
    hdu4087(概率dp)
    poj3162(树形dp+线段树)
    Gym
    牛客小白月赛13 小A的柱状图(单调栈)
  • 原文地址:https://www.cnblogs.com/lastingjava/p/10170972.html
Copyright © 2011-2022 走看看