29.3.1. 实体类
通常,JPA实体类被定义到一个persistence.xml
文件,在Spring Boot中,这个文件被'实体扫描'取代。默认情况,Spring Boot会查找主配置类(被@EnableAutoConfiguration
或@SpringBootApplication
注解的类)下的所有包。
任何被@Entity
,@Embeddable
或@MappedSuperclass
注解的类都将被考虑,一个普通的实体类看起来像这样:
注 你可以使用@EntityScan
注解自定义实体扫描路径,具体参考Section 74.4, “Separate @Entity definitions from Spring configuration”。
Last updated
Was this helpful?