我先从spring project的git上下载了Spring的源码
Spring data jpa的源码在Spring project的spring-orm/src/main/java/org/springframework/orm/jpa里
这是jpa文件夹结构
最基础的一个接口是org.springframework.data.repository.Repository,这个接口是一个空接口,接口源码为
package org.springframework.data.repository; import java.io.Serializable; /** * Central repository marker interface. Captures the domain type to manage as well as the domain type's id type. General * purpose is to hold type information as well as being able to discover interfaces that extend this one during * classpath scanning for easy Spring bean creation. * <p> * Domain repositories extending this interface can selectively expose CRUD methods by simply declaring methods of the * same signature as those declared in { @link CrudRepository}. * * @see CrudRepository * @param <T> the domain type the repository manages * @param <ID> the type of the id of the entity the repository manages * @author Oliver Gierke */ public interface Repository<T, ID extends Serializable> { }
意思是T是实体类,ID是可序列化的主键属性
然后是org.springframework.data.repository.CrudRepository接口,这个接口主要是定义了增删改查的方法,接口源码如下