Play Framework类型...已经定义 [英] Play Framework The type ... is already defined

查看:219
本文介绍了Play Framework类型...已经定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 当我尝试运行我的应用程序,它给我以下错误:

编译错误
文件/app/models/setting.java不编译。提出的错误是:类型设置已定义




  • 在models目录

  • 中的一个文件Setting.java,该文件的名称为Setting.java,而不是错误消息建议的setting.java。

  • 我不包含任何播放模块



是否有可能的播放有Windows的不区分大小写的问题?所以它会首先尝试编译模型/ Setting.java和之后的models / setting.java ??



还有什么可能是这种奇怪的行为的原因? p>

/编辑:
由于我在这里写这个问题,我没有编辑任何在我的播放应用程序,我没有重新启动它。

 文件/ app / models / staticsite.java无法编译。提出的错误是:已定义类型Staticsite 

/ EDIT2:
在浏览器中刷新此错误出现:

 无法编译/app/models/setting.java文件。提出的错误是:公共类型设置必须在其自己的文件中定义

文件IS命名为Setting .java和类IS命名为Setting

解决方案

类型已定义的上述类。如果你的类名匹配(区分大小写)并且它在自己的文件中定义,你的下一步是找出引用这个类的最近改变的代码。对我来说,问题是我的文件utils.Utils.java已经通过import utils.Utils;导入另一个文件。当我在代码中引用utils.Utils.someMethod()时,这真的混淆了编译器。我将该行更改为Utils.someMethod(),并且异常消失。



我可能应该想出一个更好的命名方案。 :/


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
  • the file is named "Setting.java" and not "setting.java" as the error message suggests
  • 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 ??

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:

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

解决方案

"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.

I probably should have come up with a better naming scheme. :/

这篇关于Play Framework类型...已经定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆