Playframework - Eclipse无法检测到新模板 [英] Playframework - Eclipse can't detect a new template
问题描述
我正在玩Play的第一步!框架和我遇到了一些问题。
我可以毫无问题地创建和超越项目。
I am doing my first steps with the Play! Framework and I run into some problems. I can create and eclipsify a project without any problems.
现在,如果我添加一个新视图,例如'sometest.scala.html',我试试在'Application'中使用它将Eclipse标记为错误。
Now if I add a new view, for example 'sometest.scala.html' and I try to use it in the 'Application' Eclipse marks this file as an error.
package controllers;
import play.*;
import play.mvc.*;
import views.html.*;;
public class Application extends Controller {
public static Result index() {
return ok(sometest.render("test")); // this line is marked red
}
}
Eclipse标记为红色,即使它有效。如果我去localhost:9000,我可以看到我的更改。
Eclipse marks sometest red, even if it works. If I go to localhost:9000, I can see my changes.
我的视图文件夹如下所示:
My view folder looks like this:
app
--views
----index.scala.html
----main.scala.html
----sometest.scala.html
我创建了一些测试作为html文件并将文件名设置为。 scala.html
I created sometest as a html file and set the file name to .scala.html
简单解决方案:
使用
run your app with
$ cd myapp
$ play
$ run
转到您的webrwoser并输入:localhost:9000
go to your webrwoser and type: localhost:9000
在您的文件中创建一个新的.scala.html文件查看文件夹。
create a new .scala.html file in your views folder.
在localhost刷新您的网站:9000
Refresh your website at localhost:9000
完成。
推荐答案
创建新视图后,您必须先在浏览器中运行应用程序,以允许Play将其编译为Scala类(可由IDE识别)然后你需要点击菜单 - > Project Build all,然后Eclipse将刷新视图。
After creating new view you have to first run the app in the browser, to allow Play to compile it as a Scala class (which are recognized by IDE) then you need to click menu -> Project Build all, then Eclipse will refresh the view.
您可以尝试使用IntelliJ,它不需要任何其他操作即可开始识别新创建的类。
Optionally you can try IntelliJ which doesn't require any additional actions to start recognizing the freshly created classes.
这篇关于Playframework - Eclipse无法检测到新模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!