【发布时间】:2016-06-14 21:13:59
【问题描述】:
我在 Intellij 中使用 Spring 和 Hibernate 以及所有 Java 8 的东西导入了一个程序,但我遇到了一个问题,即看不到 Java 8。 JDK设置好了,导入就OK了;我真的不明白为什么我的 IDE 用红色强调了这段代码。代码是:
@Entity
@Table(name = "author")
public class Author extends BaseEntity<Long> {
@Column(name = "name")
private String name;
@OneToMany(mappedBy = "author", fetch = FetchType.EAGER)
private List<Book> bookList;
public Author() {
}
public Author(String name, List<Book> bookList) {
this.name = name;
this.bookList = bookList;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public List<Book> getBookList() {
return bookList;
}
public void setBookList(List<Book> bookList) {
this.bookList = bookList;
}
public Set<Book> getBooks() { // !!!!! here lines 1
return Collections.unmodifiableSet( // 2
this.bookList.stream(). // 3
collect(Collectors.toSet()));//4 are red
}
还有import 声明:
import java.util.stream.Collectors;
也是红色的。当我点击错误时,它说:
Incompatible types.Required set <packet.model.book>
Found set <java.lang.Object>
第一方面可能是什么问题?
【问题讨论】:
标签: java spring hibernate intellij-idea