I understand the terms, groupId
, artifactId
and version
. While reading about package
, I can see it is The name of your root package. The default is the groupId
you entered before..
In that case, what is the difference between package
and groupId
?
I guess its always the same, or if they can be different than how? Someone explain
Seems like you are asking what does package
means when using Maven Archetype to generate a new Maven project.
The package
is to configure the root java package that contains all the generated source codes. So if you set the package
to com.foo.bar
, the generated project will contain a folder com/foo/bar/
in /src/main/java
.
groupId
, together with artifactId
and version
is a kind of an unique identifier of your library . That means after you package your project as a JAR and publish it to the world , other developers can import it to their project to use by specifying the correct groupId
, artifactId
and version
in their pom.xml
.
So , the package
is just the internal root package used by your project internally and it will not affect how developer locates and import your JAR to their project. The package
and the groupId
can be different.
(But of course, you are supposed to name the package to some unique name such that it does not conflict with other well-known libraries (e.g. don't name it as java.lang
or org.springframework
etc.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With