Maven groupId and package name in java source

If I have maven groupid com.mycompany.app, then I need to name my package under the name com.mycompany.app. *?

+7
source share
2 answers

No, I don't care what package names you use. Having said that, it would be nice to make them consistent so that it is a little easier to understand what the dependency is on the class.

+18
source

When creating a maven project, if you provide the groupID and package name values, maven will consider the package name to host your java class.

eg: -

mvn archetype: generate -DgroupId = gen.src -DartifactId = Iftekhar -DpackageName = com.src.Model -Dversion = 2.0-Snapshot

In the above scenerio, the App.java class will be created inside the com.src.Model package, and the value of groupId will not be considered.

But if you specified only the groupId value and not the package name, as shown below: -

mvn archetype: generate -DgroupId = com.src.Controller -DartifactId = Iftekhar -Dversion = 2.0-Snapshot

The app.java class will be created inside the com.src.Controller package.

thanks if the above answer was helpful.

0
source

All Articles