单个项目的合理组 ID?

Sensible group Id for individual project?

对于不属于任何 company/organisation/website 的 Maven 项目,组 ID 的明智选择是什么?我知道使用约定 com.companyname.projectname 是为了避免项目之间的名称空间冲突,但是我应该如何为我开始的单个项目想出一个前缀?

看看 official guide:

groupId will identify your project uniquely across all projects, so we need to enforce a naming schema. It has to follow the package name rules, what means that has to be at least as a domain name you control, and you can create as many subgroups as you want. Look at More information about package names.

eg. org.apache.maven, org.apache.commons

A good way to determine the granularity of the groupId is to use the project structure. That is, if the current project is a multiple module project, it should append a new identifier to the parent's groupId.

eg. org.apache.maven, org.apache.maven.plugins, org.apache.maven.reporting

因此,就像您为包名所做的那样,理想情况下您应该使用代表项目的域名。如果你没有,你可以想象你的项目有一个。所以 "domain you control" 可能是你的个人域,或者这个特定项目的域。 IE。 com.andyw.nextbigthingcom.nextbigthing。如果您认为它是某种东西,可以被社区收集起来很有趣,您可以跳过个人姓名并改用 org。 IE。 org.nextbigthing.

如果您使用像 GitHub 这样的流行存储库,您应该遵循 next rules:

If your project name is foo at SourceForge, you can use net.sf.foo. If your username is bar on Github, you can use com.github.bar. You can also use another reversed domain name you control. The group ID does not have to reflect the project host.