Spring Boot学习记之Maven

Maven简介

在搭建工程时,需要引入第三方jar包,可能此jar包还依赖与其他的jar包,因为没有第三方类库的依赖关系,会导致classnotfound错误,以此可以使用maven作为项目构建工具。

  1. dependencies元素

    此元素包含多个项目依赖需要使用的dependency

  2. dependency元素

    dependency元素通过groupIdartifactId以及vesion确定唯一依赖,有人称这三个为坐标。

    groupId:组织的唯一标识

    artifactId:项目的唯一标识

    version:项目的版本

<properties>

        <spring-framework.version>4.1.5.RELEASE</spring-framework.version>

</properties>

扫描二维码关注公众号,回复: 1235423 查看本文章

<dependency>

        <groupId>org.springframework</groupId>

        <artifactId>spring-webmvc</artifactId>

        <scope>${spring-framework.version}</scope>

</dependency>

 

Maven运作方式

Maven会自动根据dependency中的依赖配置,直接通过互联网在maven中心库下载相关依赖包到.m2目录下,.m2目录是你本地maven库。如果你不知道你所依赖的jar包的dependency怎么写的话。可以到http://mvnrepository.com网站检索。若maven中心库中没有你需要的jar包,你需要通过下面的maven命令打到本地maven库后应用即可,如下

mvn install:install-file -DgroupId=com.oracle “-DartifactId=ojdbc14” “-Dversion=10.2.0.2.0” “-Dpackaging=jar” “-Dfile=D:ojdbc14.jar”

猜你喜欢

转载自blog.51cto.com/11603441/2122302