我尝试搜索有关我面临的问题的堆栈溢出,但没有找到任何满意的答案。所以,请先阅读我的问题并提出建议。
我有一个 .co.in 域,我想用它来准备包。但是根据新的 Java 约定(?),不能在包名称的开头使用关键字“in”。因此,我在构建应用程序时遇到了问题。 由于 .co.mydomain.myapp 中的包名称格式,我在使用 flutter 构建 android 应用程序时遇到了问题。 在我使用 hibernate ORM 的 JavaFX 应用程序中问题仍然存在。当应用程序在 Debug模式下运行时,我看到使用实体类的完全限定名称生成的 HQL 查询导致 in.co.mydomain.myapp.entities.Student,这里“in”关键字也是 SQL 查询的保留关键字,因此它会抛出错误。
在我面临的如此可怕的情况下,我需要专家的建议。
当我将包重命名为 com.mydomain.myapp 时,整个过程没有任何问题
最佳答案
In some cases, the internet domain name may not be a valid package name. This can occur if the domain name contains a hyphen or other special character, if the package name begins with a digit or other character that is illegal to use as the beginning of a Java name, or if the package name contains a reserved Java keyword, such as "int". In this event, the suggested convention is to add an underscore.
https://docs.oracle.com/javase/tutorial/java/package/namingpkgs.html
所以你可以使用 in_.co.mydomain
关于java - 包中不能使用.in域名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58728488/