public class DataLoader implements CommandLineRunner {
private final OwnerService ownerService;
public DataLoader() {
ownerService = new OwnerServiceMap();
}
@Override
public void run(String... args) throws Exception {
System.out.println(ownerService);
}
}
@RequestMapping("/owners")
@Controller
public class OwnerController {
private final OwnerService ownerService;
public OwnerController(OwnerService ownerService) {
this.ownerService = ownerService;
}
@GetMapping({"", "/", "/index"})
public String ownersIndex(Model model) {
System.out.println(ownerService);
model.addAttribute("owners", ownerService.findAll());
return "owners/index";
}
}