【发布时间】:2021-01-17 16:08:43
【问题描述】:
我正在关注 Spring in action 第 5 版来学习 Springboot。在第 6 章时,我发现我的 IDEA IDE 似乎存在 bean org.springframework.hateoas.server.EntityLinks 的错误。
package tech.enigma.web.api;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.hateoas.server.EntityLinks;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import tech.enigma.Taco;
import tech.enigma.data.TacoRepository;
@RestController
@RequestMapping(path = "/design", produces = "application/json")
@CrossOrigin(origins = "*")
public class DesignTacoController
{
private TacoRepository tacoRepo;
private EntityLinks entityLinks;
public DesignTacoController(TacoRepository tacoRepo, EntityLinks entitylinks)
{
this.tacoRepo = tacoRepo;
this.entityLinks = entitylinks;
}
@GetMapping("/recent")
public Iterable<Taco> recentTacos()
{
PageRequest page = PageRequest.of(
0, 12, Sort.by("createAt").descending());
return tacoRepo.findAll(page).getContent();
}
}
在公共 DesignTacoController(TacoRepository tacoRepo, EntityLinks entitylinks) 构造函数中,IDEA 给出错误“无法自动装配。找不到 'EntityLinks' 类型的 bean。”我可以编译并运行我的程序,尽管我不确定它是否能正常工作。 其他豆子一切正常。 这只是IDEA的一个错误还是我有什么问题?
【问题讨论】:
标签: java spring-boot