when i try to run my Application it gives me following error:
Compilation error
The file /app/models/setting.java could not be compiled. Error raised is : The type Setting is already defined
- I do have only one file "Setting.java", which is in the models directory
- 我只有一个文件“设置”。在models目录中
- the file is named "Setting.java" and not "setting.java" as the error message suggests
- 这个文件被命名为“设置”。java”而不是“设置。如错误信息所示
- i do not include any play modules
- 我不包括任何游戏模块
I am running play on windows. Is it possible that play has problems with windows' case insensitive? So it would first try to compile models/Setting.java and after that models/setting.java ??
我在windows上运行play。是否可能play在windows的大小写不敏感方面有问题?因此,它首先尝试编译模型/设置。java和之后的模型/设置。java ? ?
What else could be the reason for this odd behavior?
还有什么原因会导致这种奇怪的行为呢?
/EDIT: Since i wrote this question here i did not edit anything at my play application and i did not restart it. Now i just refreshed the page and the same error comes again - but with another model!!
/编辑:由于我在这里写了这个问题,所以我没有在我的游戏应用程序中编辑任何东西,也没有重新启动它。现在我刷新了页面,同样的错误又出现了——但是用另一个模型!
The file /app/models/staticsite.java could not be compiled. Error raised is : The type Staticsite is already defined
/EDIT2: After a few page refreshes in the browser this error appeared:
/EDIT2:在浏览器中刷新几页后,出现以下错误:
The file /app/models/setting.java could not be compiled. Error raised is : The public type Setting must be defined in its own file
The file IS named "Setting.java" and the class IS named Setting
这个文件被命名为“设置”。和类被命名为设置
5 个解决方案
#1
3
"The type is already defined" exceptions can be raised when the issue is outside of the mentioned class. If your class name matches (case-sensitive) and it is defined in its own file, your next step is to find out what code has recently changed that references this class. For me, the issue was that my file, "utils.Utils.java", had been imported in another file via "import utils.Utils;" which really confused the compiler when I referenced "utils.Utils.someMethod()" in the code. I changed the line to "Utils.someMethod()" and the exception disappeared.
“类型已经定义”当问题在类之外时,可以提出异常。如果您的类名匹配(区分大小写),并且它是在自己的文件中定义的,那么您的下一步是找出最近修改了哪些代码引用了这个类。对我来说,问题是我的文件“utils.Utils”。java,通过“import utils.Utils”被导入到另一个文件中,当我在代码中引用“utils.Utils. somemethod()”时,这确实让编译器感到困惑。我将行改为“Utils.someMethod()”,异常消失了。
I probably should have come up with a better naming scheme. :/
我可能应该想出一个更好的命名方案。:/
#2
2
This error happens when you rename the class file that you try to compile. Simply re run the play frame work after you refract the class name. This will fix the issue.
当您重命名要编译的类文件时,会发生此错误。在重新设置类名之后,只需重新运行播放框架。这将解决问题。
#3
1
Did you have a settings.java
and replaced it with Settings.java
? Anyway, try play clean
.
你有设置吗?用Settings.java取代java?无论如何,试着打干净。
If that doesn't work, check very carefully that you don't have any problematic invisible characters in your file.
如果这不起作用,请仔细检查文件中是否有任何不可见的字符。
#4
1
I think you are working with settings.someProperty whithout declare the object "settings", and play is thinking it's a static method of the class "Settings" with an error in the capital letter.
我想你是在处理设置。someProperty whithout声明对象“settings”,play认为它是类“settings”的静态方法,大写字母中有一个错误。
#5
0
I had this issue while trying to resolve merge conflicts in git. I missed a change, and was getting this compiler error.
我在尝试解决git中的合并冲突时遇到了这个问题。我漏掉了一个修改,得到了这个编译错误。
The issue was that I had a variable of type ClassName
named className
. The variable had been deleted but this particular line was still trying to access it. Instead of reporting that the className
variable did not exist, Play did some black magic and ended up reporting the name conflict above: "Type ClassName is already defined
". There was some kind of name conflict with the ClassName
class and the className
variable.
问题是我有一个名为ClassName的类名变量。变量已被删除,但这一行仍然试图访问它。Play没有报告className变量不存在,而是做了一些黑魔法,最后报告了上面的名称冲突:“类型className已经定义”。类名类和类名变量之间存在某种名称冲突。
The fix was to just alter that line, removing the incorrect access to the old className
variable. Then run play clean
and restart your server.
修正的方法是修改这一行,删除对旧的className变量的错误访问。然后运行play clean并重新启动服务器。
#1
3
"The type is already defined" exceptions can be raised when the issue is outside of the mentioned class. If your class name matches (case-sensitive) and it is defined in its own file, your next step is to find out what code has recently changed that references this class. For me, the issue was that my file, "utils.Utils.java", had been imported in another file via "import utils.Utils;" which really confused the compiler when I referenced "utils.Utils.someMethod()" in the code. I changed the line to "Utils.someMethod()" and the exception disappeared.
“类型已经定义”当问题在类之外时,可以提出异常。如果您的类名匹配(区分大小写),并且它是在自己的文件中定义的,那么您的下一步是找出最近修改了哪些代码引用了这个类。对我来说,问题是我的文件“utils.Utils”。java,通过“import utils.Utils”被导入到另一个文件中,当我在代码中引用“utils.Utils. somemethod()”时,这确实让编译器感到困惑。我将行改为“Utils.someMethod()”,异常消失了。
I probably should have come up with a better naming scheme. :/
我可能应该想出一个更好的命名方案。:/
#2
2
This error happens when you rename the class file that you try to compile. Simply re run the play frame work after you refract the class name. This will fix the issue.
当您重命名要编译的类文件时,会发生此错误。在重新设置类名之后,只需重新运行播放框架。这将解决问题。
#3
1
Did you have a settings.java
and replaced it with Settings.java
? Anyway, try play clean
.
你有设置吗?用Settings.java取代java?无论如何,试着打干净。
If that doesn't work, check very carefully that you don't have any problematic invisible characters in your file.
如果这不起作用,请仔细检查文件中是否有任何不可见的字符。
#4
1
I think you are working with settings.someProperty whithout declare the object "settings", and play is thinking it's a static method of the class "Settings" with an error in the capital letter.
我想你是在处理设置。someProperty whithout声明对象“settings”,play认为它是类“settings”的静态方法,大写字母中有一个错误。
#5
0
I had this issue while trying to resolve merge conflicts in git. I missed a change, and was getting this compiler error.
我在尝试解决git中的合并冲突时遇到了这个问题。我漏掉了一个修改,得到了这个编译错误。
The issue was that I had a variable of type ClassName
named className
. The variable had been deleted but this particular line was still trying to access it. Instead of reporting that the className
variable did not exist, Play did some black magic and ended up reporting the name conflict above: "Type ClassName is already defined
". There was some kind of name conflict with the ClassName
class and the className
variable.
问题是我有一个名为ClassName的类名变量。变量已被删除,但这一行仍然试图访问它。Play没有报告className变量不存在,而是做了一些黑魔法,最后报告了上面的名称冲突:“类型className已经定义”。类名类和类名变量之间存在某种名称冲突。
The fix was to just alter that line, removing the incorrect access to the old className
variable. Then run play clean
and restart your server.
修正的方法是修改这一行,删除对旧的className变量的错误访问。然后运行play clean并重新启动服务器。