Skip to content

Instantly share code, notes, and snippets.


iyengarajay/ Secret

Last active Jun 5, 2017
What would you like to do?
package com.boot.jpa;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.context.annotation.Configuration;
public class ProjectInitRunner implements CommandLineRunner {
private static final Logger logger = LoggerFactory.getLogger(ProjectInitRunner.class);
private ProjectRepository projectRepository;
public void run(String... args) throws Exception {
// Save Project("Java", "Java based project for a bank")); Project("Scala", "Scala based project for an oil company")); Project("Apache Kafka", "Kafka based project for a data mining company"));
// Find all projects.
List<Project> projects = projectRepository.findAll();
projects.forEach(project ->;
// Get a project by name"Getting project by name");
Project project = projectRepository.findByName("Scala");"Scala based project id " + project.getId());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.