文章目录
pom.xml 文件
一个maven工程都有一个pom.xml文件,通过pom.xml文件定义项目的坐标、项目依赖、项目信息、插件目标等。
定义maven坐标
每个maven工程都需要定义本工程的坐标,坐标是maven对jar包的身份定义,比如:入门程序的坐标定义如下:
<!--项目名称,定义为组织名+项目名,类似包名-->
<groupId>org.westos</groupId>
<!-- 模块名称 -->
<artifactId>maven-first</artifactId>
<!-- 当前项目版本号,snapshot为快照版本即非正式版本,release为正式发布版本 -->
<version>0.0.1-SNAPSHOT</version>
<packaging > :打包类型
jar:执行package会打成jar包
war:执行package会打成war包
pom :用于maven工程的继承,通常父工程设置为pom
导入依赖常见问题
Maven项目中Failure to transfer问题以及解决方法
提示错误如下
Description Resource Path Location Type
Failure to transfer org.springframework.boot:spring-boot-maven-plugin:pom:2.1.3.RELEASE from https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer artifact org.springframework.boot:spring-boot-maven-plugin:pom:2.1.3.RELEASE from/to central (https