什么是工件,Maven为什么需要它?
当前回答
对于maven,构建过程被安排为一组工件。产品包括:
组成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.
希望这能有所帮助。
Maven在项目中组织其构建。
maven中的工件是由maven项目生成的资源。每个maven项目都可以有一个工件,比如罐子、战争、耳朵等。 项目的配置文件“pom.xml”描述了如何构建工件,如何运行单元测试等等。 通常,使用maven构建的软件项目由许多maven项目组成,这些maven项目构建了构成产品的工件(例如jar)。 如。
Root-Project // produces no artifact, simply triggers the build of the other projects
App-Project // The application, that uses the libraries
Lib1-Project // A project that creates a library (jar)
Lib2-Project // Another library
Doc-Project // A project that generates the user documentation from some resources
Maven工件并不局限于java资源。你可以生成任何你需要的资源。例如文档、项目站点、zip-archives、本地库等。
Each maven project has a unique identifier consiting of [groupId, artifactId, version]. When a maven project requires resources of another project a dependency is configured in it's pom.xml using the above-mentioned identifier. Maven then automatically resolves the dependencies when a build is triggered. The artifacts of the required projects are then loaded either from the local repository, which is a simple directory in your user's home, or from other (remote) repositories specified in you pom.xml.
问:maven中的Artifact是什么? 答:神器是一个罐子,(战争或耳朵),但它也可以是其他东西。每个藏物都有,
组ID(比如com.your.package); 一个工件ID(只是一个名字),以及 版本字符串。三者合在一起唯一地识别了这个神器。
问题:Maven为什么需要它们? 答:Maven用于使它们可用于我们的应用程序。
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存储库的文件,通常是JAR。
Maven构建生成一个或多个工件,例如编译后的JAR和“源”JAR。
每个工件都有一个组ID(通常是反向域名,如com.example.foo)、一个工件ID(只是一个名称)和一个版本字符串。三者合在一起唯一地识别了这个神器。
项目的依赖项被指定为工件。
推荐文章
- 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”之间有什么区别?