我是如何理解并使用maven的
前言
一直想写一篇关于Maven的文章,但是不知如何下笔,如果说能使用,会使用Maven的话,一、两个小时足矣,不需要搞懂各种概念。那么给大家来分享下我是如何理解并使用maven的。
什么是Maven?
Maven是一个用于项目构建的工具,通过它便捷的管理项目的生命周期。即项目的jar包依赖,开发,测试,发布打包,主要管理工作是:依赖管理,项目一键构建。
为什么要使用Maven
- 使用maven构建的项目,整个项目的体积小
- maven项目不需要手动导入jar包,通过在pom.xml中添加依赖,引用依赖会自动从maven仓库下载jar包,方便快捷。
- 项目一键构建:使用maven可以快速地对项目进行编译--测试--运行--打包--安装
- maven支持跨平台操作,可在window、linux、mac上使用
- maven遵循规范开发有利于提高大型团队的开发效率,降低项目的维护成本,属于主流技术,一般公司都会使用maven来构建项目
maven仓库的配置
ps:下载项目引用需要jar包的时候存放的本地路径
仓库的分类
- 本地仓库
- 私服(公司的仓库)
- 中央仓库
三个仓库之间的关系
三者之间的关系是,当我们在项目中依赖一个jar包时,Maven程序会先去本地仓库中找,如果没找到就回去私服找,如果还是没有,最后就回去中央仓库找。其过程如下图:
本地仓库的配置
找到已安装的maven路径,如:apache-maven-3.3.9\conf 目录下settings.xml 文件并用notepad++打开,ctrl+F找到localRepository标签,将路径设置为D:/repository,如下图:
说明:什么是本地仓库? 就是是由个人将常用到的jar包放入一个仓库中,已备自己在项目中使用,可从别人配置好的jar包仓库拷到自己本地目录,因为仓库一般很大,首次下载需要很长一段时间。
配置私服地址
实际工作中,很多项目都会用到maven私服仓库,一般公司都有统一的maven私服仓库,由于公司都是统一化管理,这时候我们就要配置统一的私服仓库,举例如下:
<mirrors> <mirror>
<!--This is used to direct the public snapshots repo in the
profile below over to a different nexus group -->
<id>nexus-public-snapshots</id>
<mirrorOf>public-snapshots</mirrorOf>
<url>http://192.168.1.118:8888/nexus/content/repositories/apache-snapshots/</url>
</mirror>
<mirror>
<!--This sends everything else to /public -->
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
</mirror>
</mirrors>
pom文件说明
pom.xml文件,一般描述了maven项目的基本信息,比如groupId,artifactId,version等,一个最简单的pom.xml文件至少需要包含四个元素:modelVersion, groupId, artiffactId和version。
比如一个基本的pom.xml文件如下:
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.test</groupId> //当前项目的信息
<artifactId>maven-demo</artifactId>
<version>1.0-SNAPSHOT</version>//SNAPSHOT(快照)表示该项目还在开发中。
</project>
其中主要的标签含义如下:
project:pom.xml 文件中的顶层元素;
modelVersion:指明 POM 使用的对象模型的版本。这个值很少改动。
groupId:指明创建项目的组织或者小组的唯一标识。
GroupId 是项目的关键标识,典型的,此标识以组织的完全限定名来定义。比如,org.apache.maven.plugins 是所有 Maven 插件项目指定的 groupId。
artifactId:指明此项目产生的主要产品的基本名称。项目的主要产品通常为一个 JAR 文件。第二,象源代码包通常使用 artifactId 作为最后名称的一部分。典型的产品名称使用这个格式:
version:项目产品的版本号。Maven 帮助你管理版本,可以经常看到 SNAPSHOT 这个版本,表明项目处于开发阶段。
在项目中添加插件,以及对插件的配置
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>//编译插件
<version>2.4.3</version>//插件的版本号
<configuration>//对插件进行配置
<source>1.7</source>//源代码编译版本
<target>1.7</target>//目标平台编译版本;
<encoding>UTF-8</encoding>//设置插件或资源文件的编码方式。
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>//执行测试用例的插件
<version>2.17</version>//插件的版本号
<configuration>//对插件进行配置
<suiteXmlFiles>
<suiteXmlFile>${suiteXmlFile}</suiteXmlFile>//测试套件执行路径
</suiteXmlFiles> </configuration>
</plugin>
</plugins>
</build>
如何在pom文件中添加依赖jar包
实际开发中需要引用jar包后,再进行开发,那么在pom中添加依赖呢?
1、比如我想添加testng.jar包,那么可以通过访问网址 https://mvnrepository.com/ ,然后在搜索框中输入testng,回车
2、点击testng,选择对应版本如6.14.3
3、复制红框中内容,放到dependencies标签内。
在pom中引用完成,并自动下载依赖jar包。
<dependencies>
<!-- https://mvnrepository.com/artifact/org.testng/testng -->
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.14.3</version>
<scope>test</scope>
</dependency>
</dependencies>
实际效果:
编写一个主类
package com.test.demo; public class HellowWorld {
public String sayHello() {
return "Hello World";
} public static void main( String[] args ) {
System.out.println(new HellowWorld().sayHello());
}
}
编写一个测试类
package com.test.demo; import org.testng.Assert;
import org.testng.annotations.Test; public class TestHellowWorld { @Test
public void testSayHello() {
HellowWorld hellowWorld = new HellowWorld();
String result = hellowWorld.sayHello();
Assert.assertEquals("Hello World", result);
}
}
maven项目的目录结构
F:\mavendemo>tree
卷 新加卷 的文件夹 PATH 列表
卷序列号为 5C5B-6DDB
F:.
├─.idea
└─src
├─main
│ ├─java
│ │ └─com
│ │ └─test
│ │ └─demo
│ └─resources
└─test
└─java
└─com
└─test
└─demo
注意上面带红色的目录名,maven项目采用“约定优于配置”的原则,src/main/java约定用于存放源代码,src/main/test用于存放单元测试代码,src/target用于存放编译、打包后的输出文件。这是全世界maven项目的通用约定,请记住这些固定的目录结构。
编译和测试
在项目根目录下运行mvn clean compile
命令。执行输出如下所示:
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building maven-demo 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ maven-demo ---
[INFO] Deleting F:\mavendemo\target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ maven-demo ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ maven-demo ---
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 1 source file to F:\mavendemo\target\classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.336 s
[INFO] Finished at: 2019-06-23T17:33:29+08:00
[INFO] Final Memory: 13M/309M
[INFO] ------------------------------------------------------------------------
clean:
清理输出目录target下生成jar包
compile:
编译项目主代码
编译完成后,我们一般都会运行测试代码进行单元测试,虽然很多情况下,我们并没有这么做,但是我还是建议大家通过Maven做一些自动化的单元测试。
测试用例编写完毕之后就可以调用Maven执行测试,运行mvn clean test
命令,输出如下:
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building maven-demo 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ maven-demo ---
[INFO] Deleting F:\mavendemo\target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ maven-demo ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ maven-demo ---
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 1 source file to F:\mavendemo\target\classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ maven-demo ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory F:\mavendemo\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:testCompile (default-testCompile) @ maven-demo ---
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 1 source file to F:\mavendemo\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.17:test (default-test) @ maven-demo ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.032 s
[INFO] Finished at: 2019-06-23T17:27:28+08:00
[INFO] Final Memory: 15M/309M
[INFO] ------------------------------------------------------------------------
打包和运行
打包就是将我们编写的应用打成JAR包或者WAR包,我们执行mvn clean package
命令就可以完成打包。mvn clean package
命令的输出如下:
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building maven-demo 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ maven-demo ---
[INFO] Deleting F:\mavendemo\target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ maven-demo ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ maven-demo ---
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 1 source file to F:\mavendemo\target\classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ maven-demo ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory F:\mavendemo\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:testCompile (default-testCompile) @ maven-demo ---
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 1 source file to F:\mavendemo\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.17:test (default-test) @ maven-demo ---
[INFO] Surefire report directory: F:\mavendemo\test-output -------------------------------------------------------
T E S T S
-------------------------------------------------------
Running com.test.demo.TestHellowWorld
Configuring TestNG with: TestNG652Configurator
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.498 sec - in com.test.demo.TestHellowWorld
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8 Results : Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 [INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ maven-demo ---
[INFO] Building jar: F:\mavendemo\target\maven-demo-1.0-SNAPSHOT.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.356 s
[INFO] Finished at: 2019-06-23T17:46:00+08:00
[INFO] Final Memory: 17M/311M
[INFO] ------------------------------------------------------------------------
运行完后,会在target目录下生成jar包
如果别的项目要引用这个JAR包时,我们将这个JAR包复制到其它项目的classpath中就OK了。
但是这样拷贝就违背了我们当初想要自动解决依赖的问题,所以如何才能让其它的Maven项目直接引用这个JAR包呢?我们需要执行mvn clean install
命令。
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building maven-demo 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ maven-demo ---
[INFO] Deleting F:\mavendemo\target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ maven-demo ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ maven-demo ---
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 1 source file to F:\mavendemo\target\classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ maven-demo ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory F:\mavendemo\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:testCompile (default-testCompile) @ maven-demo ---
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 1 source file to F:\mavendemo\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.17:test (default-test) @ maven-demo ---
[INFO] Surefire report directory: F:\mavendemo\test-output -------------------------------------------------------
T E S T S
-------------------------------------------------------
Running com.test.demo.TestHellowWorld
Configuring TestNG with: TestNG652Configurator
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.611 sec - in com.test.demo.TestHellowWorld
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8 Results : Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 [INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ maven-demo ---
[INFO] Building jar: F:\mavendemo\target\maven-demo-1.0-SNAPSHOT.jar
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ maven-demo ---
[INFO] Installing F:\mavendemo\target\maven-demo-1.0-SNAPSHOT.jar to E:\repository\com\test\maven-demo\1.0-SNAPSHOT\maven-demo-1.0-SNAPSHOT.jar
[INFO] Installing F:\mavendemo\pom.xml to E:\repository\com\test\maven-demo\1.0-SNAPSHOT\maven-demo-1.0-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.643 s
[INFO] Finished at: 2019-06-23T20:39:34+08:00
[INFO] Final Memory: 16M/211M
[INFO] ------------------------------------------------------------------------
使用Archetype生成项目骨架
下面通过用命名行创建一个最基本的maven项目
mvn archetype:generate
先创建项目的根目录,从盘符开始,命令行窗口下输入
mkdir demotest
cd demotest
mvn archetype:generate
首次运行时,mvn会从远程"中央仓库"下载一些必需的文件到"本地仓库" -
如果你有兴趣,可以在等待下载过程中,观察一下"C:\Users\当前用户名\.m2\repository"目录下是不是多了很多文件。
下载完成后,会自动进入交互模式,会让你输入一些基本信息,类似下面这样:
F:\demotest>mvn archetype:generate
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> maven-archetype-plugin:3.0.0:generate (default-cli) > generate-sources @ standalone-pom >>>
[INFO]
[INFO] <<< maven-archetype-plugin:3.0.0:generate (default-cli) < generate-sources @ standalone-pom <<<
[INFO]
[INFO] --- maven-archetype-plugin:3.0.0:generate (default-cli) @ standalone-pom ---
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-artifact-transfer/0.9.0/maven-artifact-transfer-0.9.0.pom
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-artifact-transfer/0.9.0/maven-artifact-transfer-0.9.0.pom (8 KB at 5.4 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-common-artifact-filters/3.0.0/maven-common-artifact-filters-3.0.0.pom
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-common-artifact-filters/3.0.0/maven-common-artifact-filters-3.0.0.pom (5 KB at 10.1 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-shared-components/22/maven-shared-components-22.pom
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-shared-components/22/maven-shared-components-22.pom (5 KB at 11.2 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/wagon/wagon-provider-api/2.8/wagon-provider-api-2.8.pom
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/wagon/wagon-provider-api/2.8/wagon-provider-api-2.8.pom (2 KB at 3.8 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/wagon/wagon/2.8/wagon-2.8.pom
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/wagon/wagon/2.8/wagon-2.8.pom (19 KB at 41.0 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/org/codehaus/groovy/groovy/1.8.3/groovy-1.8.3.pom
Downloaded: https://repo.maven.apache.org/maven2/org/codehaus/groovy/groovy/1.8.3/groovy-1.8.3.pom (32 KB at 26.9 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/antlr/antlr/2.7.7/antlr-2.7.7.pom
Downloaded: https://repo.maven.apache.org/maven2/antlr/antlr/2.7.7/antlr-2.7.7.pom (0 B at 0.0 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/asm/asm/3.2/asm-3.2.pom
Downloaded: https://repo.maven.apache.org/maven2/asm/asm/3.2/asm-3.2.pom (0 B at 0.0 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/asm/asm-parent/3.2/asm-parent-3.2.pom
Downloaded: https://repo.maven.apache.org/maven2/asm/asm-parent/3.2/asm-parent-3.2.pom (0 B at 0.0 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/asm/asm-commons/3.2/asm-commons-3.2.pom
Downloaded: https://repo.maven.apache.org/maven2/asm/asm-commons/3.2/asm-commons-3.2.pom (0 B at 0.0 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/asm/asm-tree/3.2/asm-tree-3.2.pom
Downloaded: https://repo.maven.apache.org/maven2/asm/asm-tree/3.2/asm-tree-3.2.pom (0 B at 0.0 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/asm/asm-util/3.2/asm-util-3.2.pom
Downloaded: https://repo.maven.apache.org/maven2/asm/asm-util/3.2/asm-util-3.2.pom (0 B at 0.0 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/asm/asm-analysis/3.2/asm-analysis-3.2.pom
Downloaded: https://repo.maven.apache.org/maven2/asm/asm-analysis/3.2/asm-analysis-3.2.pom (0 B at 0.0 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-interactivity-api/1.0-alpha-6/plexus-interactivity-api-1.0-alpha-6.pom
Downloaded: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-interactivity-api/1.0-alpha-6/plexus-interactivity-api-1.0-alpha-6.pom (0 B at 0.0 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-interactivity/1.0-alpha-6/plexus-interactivity-1.0-alpha-6.pom
Downloaded: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-interactivity/1.0-alpha-6/plexus-interactivity-1.0-alpha-6.pom (0 B at 0.0 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-components/1.1.9/plexus-components-1.1.9.pom
Downloaded: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-components/1.1.9/plexus-components-1.1.9.pom (0 B at 0.0 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-script-interpreter/1.0/maven-script-interpreter-1.0.pom
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-script-interpreter/1.0/maven-script-interpreter-1.0.pom (4 KB at 8.0 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/org/apache/ant/ant/1.8.1/ant-1.8.1.pom
Downloaded: https://repo.maven.apache.org/maven2/org/apache/ant/ant/1.8.1/ant-1.8.1.pom (0 B at 0.0 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/org/apache/ant/ant-parent/1.8.1/ant-parent-1.8.1.pom
Downloaded: https://repo.maven.apache.org/maven2/org/apache/ant/ant-parent/1.8.1/ant-parent-1.8.1.pom (0 B at 0.0 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/archetype/archetype-catalog/3.0.0/archetype-catalog-3.0.0.jar
Downloading: https://repo.maven.apache.org/maven2/net/sourceforge/jchardet/jchardet/1.0/jchardet-1.0.jar
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/archetype/archetype-common/3.0.0/archetype-common-3.0.0.jar
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/archetype/archetype-descriptor/3.0.0/archetype-descriptor-3.0.0.jar
Downloading: https://repo.maven.apache.org/maven2/jdom/jdom/1.0/jdom-1.0.jar
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/archetype/archetype-catalog/3.0.0/archetype-catalog-3.0.0.jar (19 KB at 39.7 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/org/codehaus/groovy/groovy/1.8.3/groovy-1.8.3.jar
Downloaded: https://repo.maven.apache.org/maven2/jdom/jdom/1.0/jdom-1.0.jar (0 B at 0.0 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/antlr/antlr/2.7.7/antlr-2.7.7.jar
Downloaded: https://repo.maven.apache.org/maven2/antlr/antlr/2.7.7/antlr-2.7.7.jar (0 B at 0.0 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/asm/asm/3.2/asm-3.2.jar
Downloaded: https://repo.maven.apache.org/maven2/net/sourceforge/jchardet/jchardet/1.0/jchardet-1.0.jar (26 KB at 26.5 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/asm/asm-commons/3.2/asm-commons-3.2.jar
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/archetype/archetype-descriptor/3.0.0/archetype-descriptor-3.0.0.jar (24 KB at 20.6 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/asm/asm-util/3.2/asm-util-3.2.jar
Downloaded: https://repo.maven.apache.org/maven2/asm/asm-util/3.2/asm-util-3.2.jar (0 B at 0.0 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/asm/asm-analysis/3.2/asm-analysis-3.2.jar
Downloaded: https://repo.maven.apache.org/maven2/asm/asm-analysis/3.2/asm-analysis-3.2.jar (0 B at 0.0 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/asm/asm-tree/3.2/asm-tree-3.2.jar
Downloaded: https://repo.maven.apache.org/maven2/asm/asm-commons/3.2/asm-commons-3.2.jar (33 KB at 20.2 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-utils/3.0.21/plexus-utils-3.0.21.jar
Downloaded: https://repo.maven.apache.org/maven2/asm/asm-tree/3.2/asm-tree-3.2.jar (22 KB at 10.6 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-interactivity-api/1.0-alpha-6/plexus-interactivity-api-1.0-alpha-6.jar
Downloaded: https://repo.maven.apache.org/maven2/asm/asm/3.2/asm-3.2.jar (43 KB at 19.6 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-invoker/2.2/maven-invoker-2.2.jar
Downloaded: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-interactivity-api/1.0-alpha-6/plexus-interactivity-api-1.0-alpha-6.jar (12 KB at 4.7 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-artifact-transfer/0.9.0/maven-artifact-transfer-0.9.0.jar
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-invoker/2.2/maven-invoker-2.2.jar (30 KB at 8.3 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-common-artifact-filters/3.0.0/maven-common-artifact-filters-3.0.0.jar
Downloaded: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-utils/3.0.21/plexus-utils-3.0.21.jar (240 KB at 56.1 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-script-interpreter/1.0/maven-script-interpreter-1.0.jar
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-artifact-transfer/0.9.0/maven-artifact-transfer-0.9.0.jar (121 KB at 27.4 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/org/apache/ant/ant/1.8.1/ant-1.8.1.jar
Downloaded: https://repo.maven.apache.org/maven2/org/apache/ant/ant/1.8.1/ant-1.8.1.jar (0 B at 0.0 KB/sec)
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-script-interpreter/1.0/maven-script-interpreter-1.0.jar (21 KB at 4.0 KB/sec)
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-common-artifact-filters/3.0.0/maven-common-artifact-filters-3.0.0.jar (56 KB at 10.6 KB/sec)
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/archetype/archetype-common/3.0.0/archetype-common-3.0.0.jar (324 KB at 51.1 KB/sec)
Downloaded: https://repo.maven.apache.org/maven2/org/codehaus/groovy/groovy/1.8.3/groovy-1.8.3.jar (5394 KB at 19.0 KB/sec)
[INFO] Generating project in Interactive mode
.............................................................................
执行这个命令后,后看到很多输出,然后再按照提示一步步操作,一个Maven项目就创建成功了。
总结
到此,关于maven的入门基础知识总结完毕,文章知识点相对繁琐、复杂,还请读者多次阅读和实践,如有错误之处,烦请多指正!
参考文章:
https://www.jellythink.com/archives/502
https://www.cnblogs.com/yjmyzz/p/3495762.html
我是如何理解并使用maven的的更多相关文章
- CSharpGL(55)我是这样理解PBR的
CSharpGL(55)我是这样理解PBR的 简介 PBR(Physically Based Rendering),基于物理的渲染,据说是目前最先进的实时渲染方法.它比Blinn-Phong方法的真实 ...
- vue是一个渐进式的框架,我是这么理解的
vue是一个渐进式的框架,我是这么理解的 原文地址 时间:2017-10-26 10:37来源:未知 作者:admin 每个框架都不可避免会有自己的一些特点,从而会对使用者有一定的要求,这些要求就是主 ...
- 我是这样理解EventLoop的
我是这样理解EventLoop的 一.前言 众所周知,在使用javascript时,经常需要考虑程序中存在异步的情况,如果对异步考虑不周,很容易在开发中出现技术错误和业务错误.作为一名合格的jav ...
- 我是如何理解Java抽象类和接口的
在面试中我们经常被问到:Java中抽象类和接口的区别是什么? 然后,我们就大说一通抽象类可以有方法,接口不能有实际的方法啦:一个类只能继承一个抽象类,却可以继承多个接口啦,balabala一大堆,就好 ...
- 我是如何理解ThreadLocal
ThreadLocal的概念 ThreadLocal从英文的角度看,可以看成thread和local的组合,就是线程本地的意思,我们都知道,看过jvm内存分配的人都知道在jvm虚拟机中对每一个线程都分 ...
- 我是这样理解--SVM,不需要繁杂公式的那种!(附代码)
1. 讲讲SVM 1.1 一个关于SVM的童话故事 支持向量机(Support Vector Machine,SVM)是众多监督学习方法中十分出色的一种,几乎所有讲述经典机器学习方法的教材都会介绍.关 ...
- 我是如何理解Android的Handler模型_3
AsyncTask则相当于现代化的电话系统,接线员的功能被完全封装了. 对于上例,新建更新TextView的类并继承AsyncTack类,如下: class UpdataTV extends Asyn ...
- 我是如何理解Android的Handler模型_2
对比例程说明,如: 例:在新新线程中替换TextView显示内容. 界面如下,单击按键后original data 替换为 changed data Handler Message部分实现步骤: 1. ...
- 我是这样理解HTTP和HTTPS区别的
为何要用https? http协议的缺点 通信使用明文,内容可能被窃听(重要密码泄露) 不验证通信方身份,有可能遭遇伪装(跨站点请求伪造) 无法证明报文的完整性,有可能已遭篡改(运营商劫持) 用htt ...
随机推荐
- IT兄弟连 Java语法教程 流程控制语句 经典案例
使用continue忽略本次循环剩下的语句 continue的功能和break有点类似,区别是continue只是忽略本次循环剩下的语句,接着开始下一次循环,并不会终止循环:而break则是完全终止循 ...
- Apollo的基本概念和集成实战
基本概念 使用场景 是一个分布式的配置中心.适用于微服务: 核心功能 集中管理不同环境,不同集群的配置: 配置修改后可以实时推送到应用端: 具备规范的权限,流程治理特性: 开发技术 服务端使用spri ...
- 简单node服务器demo,麻雀虽小,五脏俱全
//本服务器要实现的功能如下: //1.静态资源服务器(能读取静态资源) //2.能接收get请求,并能处理参数 //3.能接收post请求,并能处理参数 const http = require(' ...
- C# 局部类/方法
没怎么用过的东西. 算是比较神奇的东西(见识短[笑]). 关键字是partial 如果在类应用关键字,则是局部类. 如果在方法应用关键字,则是局部方法. 局部类理解差不多就是一个东西分开了,但是还是一 ...
- Oracle - v$lock查询慢原因分析
数据库内部对象X$统计信息过旧,导致v$lock查询慢 前段时间用python写了个zabbix监控脚本,里面有一个检查锁的sql语句,sql语句是这样子的select count(*) retval ...
- pandas 学习 第2篇:Series -(创建,属性,转换和索引)
序列(Series)是由一组数据(各种NumPy数据类型),以及一组与之相关的数据标签(索引)组成,序列不要求数据类型是相同的. 序列是一个一维数组,只有一个维度(或称作轴)是行(row),在访问序列 ...
- java核心技术第二篇之数据库SQL语法
#查询products表记录SELECT * FROM products WHERE price > 2000;-- 单行注释/* 多行注释*/#创建数据库CREATE DATABASE hei ...
- IOC控制反转、Unity简介
参考博客地址: Unity系列文章,推荐:http://www.cnblogs.com/qqlin/archive/2012/10/16/2717964.html https://www.cnblog ...
- JavaWeb之Servlet(3)
Servlet(3) HttpServletRequest 该类的对象封装了所以客户端提交过来的数据 获取所有请求头数据 public java.util.Enumeration<E> g ...
- [转]Outlook API
本文转自:https://www.cnblogs.com/yl153/p/6711519.html 1.Outlook简介 若要从Outlook 外控制Outlook对象,必须在编写代码的工程中建立对 ...