我正在使用以下存储库和控制器从数据库中检索一些记录:
public interface TableARepository extends CrudRepository<TableA, Long>{
@Query(value = "SELECT r FROM TableA r WHERE r.Id = :Id", nativeQuery = true)
public Rater getTableAById(@Param("Id") Long Id);
}
@RestController
public class TableAController {
@Autowired
TableARepository tableARepository;
@GetMapping(value="/GetTableAById")
public TableA getTableAById(@RequestParam String email) {
TableA tableA = new TableA();
tableA = tableARepository.getTableAById(email);
return tableA;
}
}
一旦我调用REST API,就会出现以下错误:
Cannot invoke com.TableARepository.getTableAById(Long) because this.tableARepository is null
1条答案
按热度按时间nukf8bse1#
添加注解
@Repository