【发布时间】:2019-11-14 07:26:47
【问题描述】:
我构建了简单的 REST 服务,我想从基于数据库的 id 中获取数据密钥,但是当我在 postman 中运行没有结果时,我该如何解决?
这是我的控制器
//Get Key
@RequestMapping(path="/getkey/{company_id}", method = RequestMethod.GET)
String getKey(@PathVariable int company_id) {
String encKey = null;
gkrepo.getKeyByCompanyid(company_id);
return encKey;
}
这是我的仓库
public interface GenerateKeyRepository extends JpaRepository<KeyEntity, Integer>
{
@Query(value= "SELECT * FROM tb_key", nativeQuery = true)
List<KeyEntity> getAll();
public void getKeyByCompanyid(Integer companyid);
}
【问题讨论】:
-
您是否将@Repository 注释添加到您的存储库?
-
您返回的 encKey 始终为空。
-
我不确定您如何期望从 void 方法返回某些内容。
public void getKeyByCompanyid(Integer companyid);
标签: java postgresql spring-boot web-services