在浏览器中:
Compilation error
error: cannot find symbol
In /home/william/fmj/app/controllers/Application.java at line 28.
24 public static Result deleteTask(Long id) {
25 return TODO;
26 }
27
28 static Form<Task> taskForm = form(Task.class);
29
在终点站:
[error] static Form<Task> taskForm = form(Task.class);
[error] ^
[error] symbol: class Task
[error] location: class Application
[error] /home/william/fmj/app/controllers/Application.java:16: error: cannot find symbol
[error] views.html.index.render(Task.all(), taskForm)
[error] ^
[error] symbol: variable Task
[error] location: class Application
[error] /home/william/fmj/app/controllers/Application.java:28: error: cannot find symbol
[error] static Form<Task> taskForm = form(Task.class);
[error] ^
[error] symbol: class Task
[error] location: class Application
[error] 3 errors
[error] {file:/home/william/fmj/}fmj/compile:compile: javac returned nonzero exit code
非常感谢任何帮助。我复制并粘贴了教程中的代码(http://www.playframework.org/documentation/2.0.2/JavaTodoList)我不确定出了什么问题,我真的很想学习这项技术!
答案 0 :(得分:2)
显然您没有将Task
模型导入Application
控制器
你有3个解决方案:
手动导入每个模型:
import models.Task;
将完全所有模型导入您的控制器(它在开始时会是最好的,但是......)
import models.*
packages
和classes
并建议您应该导入(或不)(即IntelliJ Idea - 只是建议)答案 1 :(得分:2)
我遇到了同样的问题(错误:找不到符号),确定我有
import models.*;
但错误仍然存在。
我正在使用eclipse 4.2,它只是建议创建新方法form(Class<Task>