Maven Getting Started Guide
This guide is intended as a reference for those working with Maven for the first time, but is also intended to serve as a cookbook with self-contained references and solutions for common use cases. For first time users, it is recommended that you step through the material in a sequential fashion. For users more familiar with Maven, this guide endeavours to provide a quick solution for the need at hand. It is assumed at this point that you have downloaded Maven and installed Maven on your local machine. If you have not done so please refer to the Download and Installation instructions.
本指南旨在作为首次使用 Maven 的人的参考,但也旨在作为一本食谱,为常见用例提供独立的参考和解决方案。对于第一次用户,建议您按顺序浏览材料。对于更熟悉 Maven 的用户,本指南努力为手头的需求提供快速解决方案。此时假设您已经下载了 Maven 并在本地机器上安装了 Maven。如果您没有这样做,请参考下载和安装说明。
Ok, so you now have Maven installed and we’re ready to go. Before we jump into our examples we’ll very briefly go over what Maven is and how it can help you with your daily work and collaborative efforts with team members. Maven will, of course, work for small projects, but Maven shines in helping teams operate more effectively by allowing team members to focus on what the stakeholders of a project require. You can leave the build infrastructure to Maven!
好的,所以你现在已经安装了 Maven,我们准备好了。在我们进入我们的例子之前,我们将简要介绍 Maven 是什么,以及它如何帮助你完成日常工作和与团队成员的合作。当然,Maven 将为小型项目工作,但是 Maven 通过允许团队成员关注项目的利益相关者需要什么来帮助团队更有效地运营。你可以把构建基础设施留给 Maven!
Sections
- What is Maven? 什么是maven?
- How can Maven benefit my development process? maven如何给我的开发过程带来帮助?
- How do I setup Maven? 如何设置?
- How do I make my first Maven project?
- How do I compile my application sources?
- How do I compile my test sources and run my unit tests?
- How do I create a JAR and install it in my local repository?
- What is a SNAPSHOT version?
- How do I use plugins?
- How do I add resources to my JAR?
- How do I filter resource files?
- How do I use external dependencies? 如何使用外部依赖?
- How do I deploy my jar in my remote repository? 如何部署我的jar包到我的远程仓库?
- How do I create documentation? 如何创建文档?
- How do I build other types of projects? 如何构建其他类型的项目?
- How do I build more than one project at once? 如何同时构建多个项目?
What is Maven?
At first glance Maven can appear to be many things, but in a nutshell Maven is an attempt to apply patterns to a project’s build infrastructure in order to promote comprehension and productivity by providing a clear path in the use of best practices. Maven is essentially a project management and comprehension tool and as such provides a way to help with managing:
- Builds
- Documentation
- Reporting
- Dependencies
- SCMs
- Releases
- Distribution
If you want more background information on Maven you can check out The Philosophy of Maven and The History of Maven. Now let’s move on to how you, the user, can benefit from using Maven.
How can Maven benefit my development process?
Maven can provide benefits for your build process by employing standard conventions and practices to accelerate your development cycle while at the same time helping you achieve a higher rate of success.
Now that we have covered a little bit of the history and purpose of Maven let’s get into some real examples to get you up and running with Maven!
How do I setup Maven?
The defaults for Maven are often sufficient, but if you need to change the cache location or are behind a HTTP proxy, you will need to create configuration. See the Guide to Configuring Maven for more information.