Getting Started
Getting Started
Examples Repository
The GitHub spring-data-examples repository hosts several examples that you can download
and play around with to get a feel for how the library works.
Hello World
Let’s start with a simple entity and its corresponding repository:
JAVA
@Entity
class Person {
JAVA
@SpringBootApplication
public class DemoApplication {
@Bean
CommandLineRunner runner(PersonRepository repository) {
return args -> {
repository.save(person);
Person saved = repository.findById(person.getId()).orElseThrow(NoSuch
};
}
}
Even in this simple example, there are a few notable things to point out:
The basic repository extends Repository . We suggest to consider how much API
surface you want to expose towards your application. More complex repository
interfaces are ListCrudRepository or JpaRepository .