maven的简单使用方法,添加公共jar和第三方jar包
来源:互联网 发布:云计算培训机构 编辑:程序博客网 时间:2024/06/05 08:33
简介:
以前去面试的时候,经常会问,会使用maven么?以前总觉得maven是个很麻烦的东西,各种配置,看都看不懂;
还不如直接下载jar 拷贝进去;为什么还要去配置maven费那个劲?
自从自己使用maven管理项目之后,才发现,maven简直太强大了,保证你用过一次,你就再也不想用下载,拷贝jar包的方法了。
步骤:
1.下载maven安装
2.配置maven环境,和配置jdk差不多,自行百度
3.在开发工具里面创建maven项目,方法自行百度
4.pom.xml是maven的配置文件,所有配置都在里面,具体配置自行百度
pom.xml:
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.yuan</groupId>
<artifactId>YuanxmMavenExample</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>YuanxmMavenExample Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
------------------------------------------------- start
<!-- spring jar begin-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>4.3.7.RELEASE</version>
</dependency>
<!-- spring jar end-->
------------------------------------------------- end 你只需要添加以上配置,保存之后,maven就自动帮你下载4.3.7版本的spring , jar包了。这个配置信息可以上spring的官网查询
--------------------------------------------- start
<!-- install-plugin jar begin-->
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>2.3.1</version>
</dependency>
<!-- install-plugin jar end-->
---------------------------------------------- end 以上配置,是为了添加maven的插件,因为大多数jar,只要有配置信息,maven就可以帮你下载,但是不排除没有配置信息的,所以要自己导入,这个插件用来导入第三方jar包
maven 插件版本查询地址: http://mvnrepository.com/artifact/org.apache.maven.plugins
导入第三方jar包例子:
第一步 配置maven环境之后在dos下:
mvn install:install-file -DgroupId=org.jotm(自己根据jar的意义名) -DartifactId=j-jotm(自己根据意义命名) -Dversion=1.6.8 -Dpackaging=jar -Dfile=D:\springframeworkjar\jotm.jar(本地jar包位置)
一些参数说明如下:
-DgroupId=远程仓库对应的DgroupId
-DartifactId= 远程仓库对应的 DartifactId
-Dversion=对应版本号
第二部 在pom.xml里面加入配置maven就会导入(注意,第一步只是把jar放入了maven,这里才是把jar导入项目)
<!-- org.jotm jar begin-->
<dependency>
<groupId>org.jotm</groupId>
<artifactId>j-jotm</artifactId>
<version>1.6.8</version>
</dependency>
<!-- org.jotm jar end-->
<build>
完毕!
maven 仓库地址:http://mvnrepository.com 查询 依赖配置
- maven的简单使用方法,添加公共jar和第三方jar包
- maven添加第三方的jar和源代码jar
- 关于maven 添加第三方jar包
- maven 手动添加第三方的jar包
- maven 手动添加第三方的jar包
- maven 手动添加第三方的jar包
- maven 手动添加第三方的jar包
- maven 手动添加第三方的jar包
- maven 手动添加第三方的jar包
- Maven优雅的添加第三方Jar包
- Maven优雅的添加第三方Jar包
- MAVEN手工添加第三方jar包(ojdbc14.jar)
- MAVEN手工添加第三方jar包(ojdbc14.jar)
- maven 添加第三方jar
- maven添加第三方jar
- maven添加第三方jar包进本地maven库
- maven添加第三方jar包进本地maven库
- 在maven中添加第三方jar包
- 什么是泛型?
- TCP第四次挥手为什么要等待2MSL
- 【九度OJ】题目1201:二叉排序树 解题报告
- Linux进程创建之fork()函数
- C++之多态(纯虚函数+RTTI+异常处理)
- maven的简单使用方法,添加公共jar和第三方jar包
- 【HDU-oj】-4920-Matrix multiplication(矩阵,裸)
- 关于hololens调用讯飞语音sdk问题汇总
- Angular开发者指南(一)入门介绍
- poj2251(翻译)
- 在Oracle 11.2.0.3.0上开启大页(hugepages)的详细解析
- 734C Anton and Making Potions
- CentOs 6.5下安装jdk1.7
- i18next的使用