zoukankan      html  css  js  c++  java
  • SpringCloud使用jpa之Rest方式

    这个与上一篇的基本相同,需要修改的只有Dao层的文件:

    TablesDao.java

    package com.shinho.dao;
    
    import org.springframework.data.jpa.repository.Query;
    import  org.springframework.data.repository.CrudRepository;
    import org.springframework.data.rest.core.annotation.RepositoryRestResource;
    
    import com.shinho.entity.Tables;
    
    @RepositoryRestResource(collectionResourceRel = "people", path = "people")
    public interface TablesDao extends CrudRepository<Tables, Integer> {
        
        @Query(value="select count(*) from props",nativeQuery=true)
        int getcount();
    }

    这里有个学问,就是访问的地址,是这样一个规则,比如现在看到的这个getcount的方法:

    http://localhost:7088/people/search/getcount

    蛋疼!

    还有,这个东西是Spring Data JPA,一定要看官网,不要看网上的野文!

    官网地址:http://projects.spring.io/spring-data-jpa/

  • 相关阅读:
    Android访问数据库(SQL Server 和 MySQL)
    Andriod开发环境搭建
    SQL 学习记录
    安装双系统 win7 + ubuntu 15.04
    SQL资料
    电脑使用
    python_L7
    ONE
    网页性能优化
    js的继承
  • 原文地址:https://www.cnblogs.com/wpcnblog/p/8945280.html
Copyright © 2011-2022 走看看