Maven groupId and package name in java source
If I have a maven groupid com.mycompany.app, does it mean I need to name my package under the name of com.mycompany.app.*?
No, maven doesn't care what package names you use. Having said that, it's not a bad idea to make them consistent to make it a little easier to see which dependency a class comes from.
While creating a maven project if you have mentioned values for both groupId and package name, then maven will consider the package name to place your java class.
For example:
mvn archetype:generate -DgroupId=gen.src -DartifactId=Iftekhar -DpackageName=com.src.Model -Dversion=2.0-Snapshot
In the above scenario App.java class will be created inside the package com.src.Model and the groupId value will not be considered.
But if you have mentioned only groupId value (and not package name) like below:
mvn archetype:generate -DgroupId=com.src.Controller -DartifactId=Iftekhar -Dversion=2.0-Snapshot
Then App.java class will be created inside the package com.src.Controller.
加载中,请稍侯......
精彩评论