java java源中的Maven groupId和包名
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5214075/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Maven groupId and package name in java source
提问by user496949
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.*?
如果我有一个 maven groupid com.mycompany.app,是否意味着我需要将我的包命名为 com.mycompany.app.*?
回答by tgdavies
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.
不,maven 不关心你使用什么包名。话虽如此,让它们保持一致以便更容易查看类来自哪个依赖项并不是一个坏主意。
回答by user3747182
While creating a maven project if you have mentioned both groupID and package name values then maven will consider the package name to place your java class.
在创建 maven 项目时,如果您同时提到了 groupID 和包名称值,那么 maven 将考虑包名称来放置您的 java 类。
for e.g:-
例如:-
mvn archetype:generate -DgroupId=gen.src -DartifactId=Iftekhar -DpackageName=com.src.Model -Dversion=2.0-Snapshot
mvn 原型:生成 -DgroupId=gen.src -DartifactId=Iftekhar -DpackageName=com.src.Model -Dversion=2.0-Snapshot
In the above scenerio App.java class will be created inside the package com.src.Model and the groupId value will not be considered.
在上面的场景中,App.java 类将在包 com.src.Model 内创建,并且不会考虑 groupId 值。
But if you have mentioned only groupId value and not package name like below:-
但是,如果您只提到了 groupId 值而不是像下面这样的包名称:-
mvn archetype:generate -DgroupId=com.src.Controller -DartifactId=Iftekhar -Dversion=2.0-Snapshot
mvn 原型:生成 -DgroupId=com.src.Controller -DartifactId=Iftekhar -Dversion=2.0-Snapshot
App.java class will be created inside the package com.src.Controller.
App.java 类将在包 com.src.Controller 中创建。
thanks if the above answer was helpful..
谢谢如果上面的答案有帮助..