Does maven rely on a local project or a warehouse jar package?

Source: Internet
Author: User

I believe everyone has met the dependency of MAVEN configuration or is a jar or a project, in the process of development, we certainly need to introduce the project, so that when you look at the files maven depends on, you can directly see the source Code.

first, The local project relies on

For example, the architecture is shown below (all of the following are demonstrated using the Eclipse M2eclipse plugin)--

  

At this point, the "dependency-to-hello" relied on here refers to the project in the Eclipse workspace, so that our direct source depends on the source code in the workspace, which is very convenient, and we need. Notice that the "dependency-to-hello" project on which it is dependent does not show its path and is the address of the default Workspace.

so, when does maven depend on the jar packages in the warehouse (local warehouse or remote warehouse)?

second, (local/remote) Warehouse jar Package Dependencies

One of the simple ways to shut down the "dependency-to-hello" project directly (close Project) so that you get a view

  

As you can see, maven relies on the jar file that corresponds to the "dependency-to-hello" project, and the following path appears to be taken from the Maven Repository.

III. Conversion of engineering dependencies and warehouse dependencies

ok, We now restore it, we will project "dependency-to-hello" open, will see the corresponding Maven dependency back to the original project Dependent.

What needs to say is that when re-opening the project "dependency-to-hello", The Hello Project did not appear red exclamation point, that is, do not need to do "update dependencies" and other updates maven dependencies and other Operations.

From here, we can see That.--m2eclipse first to see if it is possible to get a corresponding Maven dependency from the local engineering library, how to exist, to rely on the local project, and how to load the corresponding jar dependencies from the local repository/remote repository.

Iv. Change of version number

here, I pretend to mock the version number change, see what happens?

Now that the "dependency-to-hello" project is a "snapshot" version, when we change it to the official version, the maven dependency of the "hello" project is changed back to the jar dependency, as follows--

Maven coordinate configuration for "dependency-to-hello" project--

<groupId>com.juvenxu.mvnbook</groupId><artifactId>dependency-to-hello</artifactId>< Version>0.0.1</version><packaging>jar</packaging>

Dependency configuration of the "hello" project--

<dependency>    <groupId>com.juvenxu.mvnbook</groupId>    <artifactId> Dependency-to-hello</artifactid>    <version>0.0.1-SNAPSHOT</version></dependency>

The file schema is displayed as follows--

  

Will find its dependencies on the "snapshot" version of the "dependency-to-hello" jar package in the original repository. We removed the "snapshot" version from the Repository. Refresh the project and find the red exclamation mark displayed on the Hello Project. As follows--

  

In other words, its dependencies are null-dependent, and neither local nor warehouse Exists.

of course, This "trap" is my own add, re-change its version number correctly corresponding, you can re-get maven local engineering Dependency.

V. Summary

In everyday multiplayer collaborative development, we often encounter problems with Maven-dependent version Changes. When there is a corresponding dependency project in our workspace (corresponding to the "dependency-to-hello" project in the example above), we can determine whether there is a problem of version inconsistency by judging how the local project or the warehouse jar package is Dependent. As a result, you can solve the problem of Maven dependent version Changes.

Original Address: http://www.cnblogs.com/jinguangguo/p/maven.html

Does maven rely on a local project or a warehouse jar package?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.