Advertisement
kauuu

Untitled

Feb 23rd, 2022
611
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.04 KB | None | 0 0
  1. package com.example.demo.student;
  2.  
  3. import org.springframework.boot.CommandLineRunner;
  4. import org.springframework.context.annotation.Bean;
  5. import org.springframework.context.annotation.Configuration;
  6. import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
  7.  
  8. import java.time.LocalDate;
  9. import java.time.Month;
  10. import java.util.List;
  11.  
  12. @EnableJpaRepositories
  13. @Configuration
  14. public class StudentConfig {
  15.  
  16.     @Bean
  17.     CommandLineRunner commandLineRunner(StudentRepository repository) {
  18.         return args -> {
  19.             Student mariam = new Student(
  20.                     "Mariam",
  21.                     "[email protected]",
  22.                     19,
  23.                     LocalDate.of(2002, Month.NOVEMBER, 25)
  24.             );
  25.  
  26.             Student alex = new Student(
  27.                     "Alex",
  28.                     "[email protected]",
  29.                     21,
  30.                     LocalDate.of(2000, Month.NOVEMBER, 5)
  31.             );
  32.  
  33.             repository.saveAll(List.of(mariam, alex));
  34.         };
  35.     }
  36. }
  37.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement