开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜