开发工具与关键技术: Java
作者:肖广斌
撰写时间:2020年10月8日

在我们刚新建完一个maven web项目的时候,都会有一个pom.xml文件,文件的开头一般都是我们在新建项目时候填写的基本信息,比如有标识,打包方式还有项目名称什么的,如下图
在这里插入图片描述
那么在这个xml文件中我们应该配置写什么呐,我们可以在里面配置我们项目所需要用到的组件依赖,在配置组件依赖前我们先需要去官网下载一个apache-maven-3.6.3,(这里我用的是3.6.3)然后解压,接着我们需要修改一下它的配置,打开解压完成后的apache-maven找到settings.xml文件,用记事本打开,把localRepository本地仓库的路径修改成自己想要放置的路径,再往下找mirror,配置一个阿里云公共仓库的下载路径,就是说如果你的配置文件中有依赖包,那么它首先就会在你本地仓库找,如果本地仓库找不到,就会去阿里云公共仓库下载到你的本地仓库里,如下图
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
修改完成后,把它导入eclipse中选择并应用,把路径修改成刚刚的settings.xml文件的路径点击update就行了
在这里插入图片描述
在这里插入图片描述
接着我们就在pom.xml文件中根据项目需求配置项目相关的依赖,使用标签在里面添加配置相关的依赖包和版本号,还可以配置mapper的xml文件和其他资源位置,只要使用对应的标签进行配置就行,配置我们的项目编译插件jdk的版本等,如果我们本地仓库中没有这些依赖包的话,需要联网它才能在阿里云公共仓库中下载喔,下载时不要随便中断网络,不然可能引发各种报错
在这里插入图片描述
在这里插入图片描述

GitHub 加速计划 / ma / maven
36
2
下载
Maven: Apache Maven是一个开源的项目管理和构建工具,主要用于Java项目。适合需要自动化项目构建和依赖管理的开发者。特点包括约定优于配置、易于使用和社区驱动。
最近提交(Master分支:1 个月前 )
405e2e10 The root cause was that ModelBuilderResult.getActivePomProfiles() returned all active profiles as a flat list without tracking which model each profile came from. This commit: - Adds getActivePomProfiles(String modelId) and getActivePomProfilesByModel() methods to ModelBuilderResult API to track profiles per model like Maven 3 did - Updates DefaultModelBuilder to track model IDs when adding profiles, using ModelProblemUtils.toId() to get groupId:artifactId:version format (without packaging) to match Maven 3 behavior - Updates DefaultProjectBuilder to use the new per-model profile tracking API to correctly set injected profile IDs - Adds integration test MavenITgh11409ProfileSourceTest to verify the fix and prevent regression Profile sources now correctly show groupId:artifactId:version format, matching Maven 3 behavior. Fixes #11409 18 小时前
7d6fd870 This commit addresses two issues with BOM (Bill of Materials) handling in consumer POMs: 1. BOM packaging not transformed to POM in consumer POMs: When a project uses packaging=bom, the consumer POM was incorrectly retaining this packaging type. Since 'bom' is not a valid packaging type in Maven 4.0.0 model, this caused errors when the consumer POM was used. The fix ensures that BOM packaging is always transformed to 'pom' in consumer POMs, regardless of whether flattening is enabled. 2. Dependency versions preserved in dependencyManagement: The effective model already contains resolved versions for dependencies in dependencyManagement sections. The fix ensures these versions are properly preserved in the consumer POM for both flattened and non-flattened BOMs. Changes: - Modified DefaultConsumerPomBuilder.build() to detect BOMs based on original packaging and handle them appropriately - Added buildBomWithoutFlatten() method to handle BOMs when flattening is disabled, using the raw model but still transforming packaging - Added integration test to verify both issues are fixed Fixes issues reported in: https://lists.apache.org/thread/41q40v598pd8mr32lmgwdfb2xm7lzm6l 19 小时前
Logo

新一代开源开发者平台 GitCode,通过集成代码托管服务、代码仓库以及可信赖的开源组件库,让开发者可以在云端进行代码托管和开发。旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐