Java Questions
Java Questions

Reputation: 7953

What will happen if I don't specify a version for a Maven dependency?

i have seen in the project maven dependency specified like the following,

        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi</artifactId>
        </dependency>

there is no version defined in the dependency, so what will happen if i don't give version name and why it is given like above.

would some one explain the reason please.

Upvotes: 19

Views: 11737

Answers (2)

Alankar
Alankar

Reputation: 55

I have put the following maven dependency with a version in my pom.xml and it is working fine. <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-antrun-plugin</artifactId> <executions>

Upvotes: -1

NilsH
NilsH

Reputation: 13821

I don't think you can do that in the ordinary dependency section of your poject. The only case I know that this is allowed is when you inherit a parent project with a <dependencyManagement> section, which is used to coordinate dependency versions across a set of projects. Then you can use the "shorthand" definition, without the version. But it would still have a version, which it inherits from the dependency defined in the parent project.

There are some other places in the pom you can drop the version as well, but those are not directly relevant to including dependencies (like plugins/exludes etc).

Upvotes: 18

Related Questions