什么是工件,Maven为什么需要它?
当前回答
工件是部署到Maven存储库的文件,通常是JAR。
Maven构建生成一个或多个工件,例如编译后的JAR和“源”JAR。
每个工件都有一个组ID(通常是反向域名,如com.example.foo)、一个工件ID(只是一个名称)和一个版本字符串。三者合在一起唯一地识别了这个神器。
项目的依赖项被指定为工件。
其他回答
工件是一个JAR或存储在存储库中的东西。Maven将它们取出并构建您的代码。
我知道这是一个古老的线索,但我想添加一些细微差别。
有Maven构件,存储库管理器构件,还有Maven构件。
Maven工件正如其他评论者/响应者所说:它是通过构建Maven项目而产生的东西。可以是。jar文件,或。war文件,或。zip文件,或。dll文件,等等。
存储库管理器工件是由存储库管理器管理的东西。存储库管理器基本上是用于软件可执行文件和库的高性能命名服务。存储库管理器并不关心其构件来自何处(可能来自Maven构建、本地文件、Ant构建或手工编译……)。
Maven Artifact是一个Java类,它表示由存储库管理器解引用到存储库管理器工件的那种“名称”。当在这种意义上使用时,Artifact只是一个由groupId、artifactId、版本、范围、分类器等部分组成的美化名称。
把它们放在一起:
Your Maven project probably depends on several Artifacts by way of its <dependency> elements. Maven interacts with a repository manager to resolve those Artifacts into files by instructing the repository manager to send it some repository manager artifacts that correspond to the internal Artifacts. Finally, after resolution, Maven builds your project and produces a Maven artifact. You may choose to "turn this into" a repository manager artifact by, in turn, using whatever tool you like, sending it to the repository manager with enough coordinating information that other people can find it when they ask the repository manager for it.
希望这能有所帮助。
Usually, when you create a Java project you want to use functionalities made in another Java projects. For example, if your project wants to send one email you dont need to create all the necessary code for doing that. You can bring a java library that does the most part of the work. Maven is a building tool that will help you in several tasks. One of those tasks is to bring these external dependencies or artifacts to your project in an automatic way ( only with some configuration in a XML file ). Of course Maven has more details but, for your question this is enough. And, of course too, Maven can build your project as an artifact (usually a jar file ) that can be used or imported in other projects.
这个网站上有几篇关于Maven的文章:
https://connected2know.com/programming/what-is-maven/
https://connected2know.com/programming/maven-configuration/
工件是项目可以使用或生成的元素。在Maven术语中,工件是Maven项目构建后生成的输出。例如,它可以是jar、war或任何其他可执行文件。
此外,Maven工件包括五个关键元素,groupId、artifactId、版本、打包和分类器。这些是我们用来识别工件的元素,被称为Maven坐标。
从这里开始阅读
问:maven中的Artifact是什么? 答:神器是一个罐子,(战争或耳朵),但它也可以是其他东西。每个藏物都有,
组ID(比如com.your.package); 一个工件ID(只是一个名字),以及 版本字符串。三者合在一起唯一地识别了这个神器。
问题:Maven为什么需要它们? 答:Maven用于使它们可用于我们的应用程序。
推荐文章
- javax.transaction.Transactional vs . org.springframework.transaction.annotation.Transactional
- Java 8接口方法中不允许“同步”的原因是什么?
- 如何找到Java堆大小和内存使用(Linux)?
- 使用Enum实现单例(Java)
- RabbitMQ与通道和连接之间的关系
- buildSessionFactory()配置方法在Hibernate中已弃用?
- Spring MVC -如何获得所有的请求参数在一个地图在Spring控制器?
- Xcode的构建文件夹在哪里?
- 如何在Java中按两个字段排序?
- 文件之间的差异。路径中的分隔符和斜杠
- 在方法参数中使用NotNull注释
- Spring MVC中处理可选参数的@RequestParam
- 禁用maven下载进度指示
- Tomcat:如何查找正在运行的Tomcat版本?
- “java”、“javaw”和“javaws”之间有什么区别?