Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.example.demo.student;
- import org.springframework.boot.CommandLineRunner;
- import org.springframework.context.annotation.Bean;
- import org.springframework.context.annotation.Configuration;
- import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
- import java.time.LocalDate;
- import java.time.Month;
- import java.util.List;
- @EnableJpaRepositories
- @Configuration
- public class StudentConfig {
- @Bean
- CommandLineRunner commandLineRunner(StudentRepository repository) {
- return args -> {
- Student mariam = new Student(
- "Mariam",
- 19,
- LocalDate.of(2002, Month.NOVEMBER, 25)
- );
- Student alex = new Student(
- "Alex",
- 21,
- LocalDate.of(2000, Month.NOVEMBER, 5)
- );
- repository.saveAll(List.of(mariam, alex));
- };
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement