**结案。**此问题不可复制或由打字错误引起。它目前不接受答案。
**想改进这个问题吗?**更新问题,使其成为堆栈溢出的主题。
两年前关门了。
改进这个问题
我使用的是playframework2.5.10编译错误 }' expected but eof found.
. 我未能匹配某些未命中代码。在哪里调试?
这是我的书.java中的模型
package models;
public class Book{
public Integer id;
public String title;
public Integer price;
public String author;
public Book(Integer id, String title, Integer price, String author){
this.id = id;
this.title = title;
this.price = price;
this.author = author;
}
private static Set<Book> books;
static {
books = new HashSet<>();
books.add(new Book(id: 1, title: "C++", price : 10, author: "ABC");
books.add(new Book(id: 2, title: "Java", price : 20, author: "DEF");
}
public static Set<Book> allBooks(){
return books;
}
public static Book findById(Integer id) {
for (Book book : books) {
if (id.equals(book.id)) {
return book;
}
}
return null;
}
public static void add (Book book){
books.add(book);
}
public static boolean remove(Book book){
return books.remove(book);
}
}
这是编译错误
[info] Compiling 1 Scala source and 3 Java sources to /Users/Play/PROJ_NAME/target/scala-2.11/classes...
[error] /Users/Play/PROJ_NAME/app/models/Book.java:46: `}' expected but eof found.
[error] }
[error] ^
[error] one error found
[error] (compile:compileIncremental) Compilation failed
[info] Compiling 1 Scala source and 3 Java sources to /Users/Play/PROJ_NAME/target/scala-2.11/classes...
[error] /Users/Play/PROJ_NAME/app/models/Book.java:46: `}' expected but eof found.
[error] }
[error] ^
[error] one error found
[error] (compile:compileIncremental) Compilation failed
[error] application -
! @7a6fl9c3b - Internal server error, for (GET) [/books] ->
play.sbt.PlayExceptions$CompilationException: Compilation error[`}' expected but eof found.]
at play.sbt.PlayExceptions$CompilationException$.apply(PlayExceptions.scala:27)
at play.sbt.PlayExceptions$CompilationException$.apply(PlayExceptions.scala:27)
at scala.Option.map(Option.scala:145)
at play.sbt.run.PlayReload$$anonfun$taskFailureHandler$1.apply(PlayReload.scala:49)
at play.sbt.run.PlayReload$$anonfun$taskFailureHandler$1.apply(PlayReload.scala:44)
at scala.Option.map(Option.scala:145)
at play.sbt.run.PlayReload$.taskFailureHandler(PlayReload.scala:44)
at play.sbt.run.PlayReload$.compileFailure(PlayReload.scala:40)
at play.sbt.run.PlayReload$$anonfun$compile$1.apply(PlayReload.scala:17)
at play.sbt.run.PlayReload$$anonfun$compile$1.apply(PlayReload.scala:17)
谢谢你的帮助!
1条答案
按热度按时间kcrjzv8t1#
你的
static
街区关闭了,你错过了任何一个import
(s) 是的。java没有命名字典参数语法,它应该看起来像确保你