我使用 Spring 和 Hibernate 以及所有 Java 8 的东西在 Intellij 中导入了一个程序,但我遇到了一个问题,即看不到 Java 8。 JDK已设置并且导入正常;我真的不明白为什么我的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 - 无法识别java 8 lambda但配置没问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37822205/