{"id":87,"date":"2019-03-06T12:49:32","date_gmt":"2019-03-06T12:49:32","guid":{"rendered":"https:\/\/www.kindsonthegenius.com\/spring-boot\/?p=87"},"modified":"2020-07-26T08:12:43","modified_gmt":"2020-07-26T08:12:43","slug":"10-spring-boot-using-the-business-service","status":"publish","type":"post","link":"https:\/\/www.kindsonthegenius.com\/spring-boot\/10-spring-boot-using-the-business-service\/","title":{"rendered":"Spring Boot &#8211; Using the Business Service"},"content":{"rendered":"<p>We would learn about how to use the business services we created previously. We actually will move the logic from the controller to the business service.<\/p>\n<p>&nbsp;<\/p>\n<ol>\n<li><a href=\"#t1\">How Business Service Work<\/a><\/li>\n<li><a href=\"#t2\">Adding Dependency to the Controller<\/a><\/li>\n<li><a href=\"#t3\">The UserService and Controller<\/a><\/li>\n<li><a href=\"#t4\">The PostService and Controller<\/a><\/li>\n<li><a href=\"#t5\">The Location Service and Controller<\/a><\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<h4><strong id=\"t1\">1. How Business Service Work<\/strong><\/h4>\n<p>Remember that we already wrote a method to get items. For instance, getAllUsers returns list of all the users. In the same way, getAllLocations returns list of all location. We wrote these methods in the controller file. The fact is that we actually need to get these information from the business service.Business Service is also called Data Access Layer.<\/p>\n<p>So if we need a list of users, we ask the business service to provide it. Also if we need a list of locations, we simply ask the business service and so on.<\/p>\n<p>This then means that the controller should actually be talking to the business service.<\/p>\n<p>However all this is made possible by <a href=\"https:\/\/www.kindsonthegenius.com\/what-is-dependency-injection-with-java-examples\/\">Dependency Injection<\/a>.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h4><strong id=\"t2\">2. Add the Dependencies to the Controllers\u00a0<\/strong><\/h4>\n<p>We need to enable dependency injection in our controller files.\u00a0 To to that, we take two steps:<\/p>\n<ul>\n<li>Create a private member variable in the controller class<\/li>\n<li>Add the @Autowired annotation to this member variable<\/li>\n<li>The move the get methods over to the business service<\/li>\n<\/ul>\n<p>So when application starts, a new instance of the business service is created and registered. Then when a controller is created, Spring checks if there is an @Autowired annotation. If yes, then it takes the existing instance of the business service and injects it into the controller.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h4><strong id=\"t3\">3. The User Service and Controller<\/strong><\/h4>\n<p>After adding the dependency injection to the UserController and moving the getAllUser() method to the UserService, the the User controller would be as below:<\/p>\n<p>&nbsp;<\/p>\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #008800; font-weight: bold;\">package<\/span> com<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">kindsonthegenius<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">social<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">user<\/span><span style=\"color: #333333;\">;<\/span>\r\n\r\n<span style=\"color: #008800; font-weight: bold;\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold;\">java.util.Arrays<\/span><span style=\"color: #333333;\">;<\/span>\r\n<span style=\"color: #008800; font-weight: bold;\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold;\">java.util.List<\/span><span style=\"color: #333333;\">;<\/span>\r\n\r\n<span style=\"color: #008800; font-weight: bold;\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold;\">org.springframework.beans.factory.annotation.Autowired<\/span><span style=\"color: #333333;\">;<\/span>\r\n<span style=\"color: #008800; font-weight: bold;\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold;\">org.springframework.web.bind.annotation.RequestMapping<\/span><span style=\"color: #333333;\">;<\/span>\r\n<span style=\"color: #008800; font-weight: bold;\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold;\">org.springframework.web.bind.annotation.RestController<\/span><span style=\"color: #333333;\">;<\/span>\r\n\r\n<span style=\"color: #008800; font-weight: bold;\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold;\">com.kindsonthegenius.social.location.Location<\/span><span style=\"color: #333333;\">;<\/span>\r\n\r\n<span style=\"color: #555555; font-weight: bold;\">@RestController<\/span>\r\n<span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #008800; font-weight: bold;\">class<\/span> <span style=\"color: #bb0066; font-weight: bold;\">userController<\/span> <span style=\"color: #333333;\">{<\/span>\r\n\t\r\n\t<span style=\"color: #555555; font-weight: bold;\">@Autowired<\/span>\r\n\t<span style=\"color: #008800; font-weight: bold;\">private<\/span> UserService userService<span style=\"color: #333333;\">;<\/span>\r\n\t\r\n\t<span style=\"color: #555555; font-weight: bold;\">@RequestMapping<\/span><span style=\"color: #333333;\">(<\/span>value<span style=\"color: #333333;\">=<\/span><span style=\"background-color: #fff0f0;\">\"\/users\"<\/span><span style=\"color: #333333;\">)<\/span>\r\n\t<span style=\"color: #008800; font-weight: bold;\">public<\/span> List<span style=\"color: #333333;\">&lt;<\/span>User<span style=\"color: #333333;\">&gt;<\/span> <span style=\"color: #0066bb; font-weight: bold;\">getAllUsers<\/span><span style=\"color: #333333;\">()<\/span> <span style=\"color: #333333;\">{<\/span>\r\n\r\n\t\t<span style=\"color: #008800; font-weight: bold;\">return<\/span> userService<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">getAllUsers<\/span><span style=\"color: #333333;\">();<\/span>\t\r\n\t<span style=\"color: #333333;\">}<\/span>\r\n<span style=\"color: #333333;\">}<\/span>\r\n<\/pre>\n<p>Listing 1.0: The UserController Class<\/p>\n<p>&nbsp;<\/p>\n<p>Similarly, the userService would now contain the definition for list of Users as shown below<\/p>\n<p>&nbsp;<\/p>\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #008800; font-weight: bold;\">package<\/span> com<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">kindsonthegenius<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">social<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">user<\/span><span style=\"color: #333333;\">;<\/span>\r\n\r\n<span style=\"color: #008800; font-weight: bold;\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold;\">java.util.Arrays<\/span><span style=\"color: #333333;\">;<\/span>\r\n<span style=\"color: #008800; font-weight: bold;\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold;\">java.util.List<\/span><span style=\"color: #333333;\">;<\/span>\r\n\r\n<span style=\"color: #008800; font-weight: bold;\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold;\">org.springframework.stereotype.Service<\/span><span style=\"color: #333333;\">;<\/span>\r\n\r\n<span style=\"color: #008800; font-weight: bold;\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold;\">com.kindsonthegenius.social.location.Location<\/span><span style=\"color: #333333;\">;<\/span>\r\n\r\n<span style=\"color: #555555; font-weight: bold;\">@Service<\/span>\r\n<span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #008800; font-weight: bold;\">class<\/span> <span style=\"color: #bb0066; font-weight: bold;\">UserService<\/span> <span style=\"color: #333333;\">{<\/span>\r\n\t\r\n   User user1 <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> User<span style=\"color: #333333;\">(<\/span>\r\n\t<span style=\"background-color: #fff0f0;\">\"u1\"<\/span><span style=\"color: #333333;\">,<\/span> \r\n\t<span style=\"background-color: #fff0f0;\">\"Jany\"<\/span><span style=\"color: #333333;\">,<\/span> \r\n\t<span style=\"background-color: #fff0f0;\">\"Lawrence\"<\/span><span style=\"color: #333333;\">,<\/span>\r\n\t<span style=\"color: #008800; font-weight: bold;\">new<\/span> <span style=\"color: #0066bb; font-weight: bold;\">Location<\/span><span style=\"color: #333333;\">(<\/span><span style=\"background-color: #fff0f0;\">\"l1\"<\/span><span style=\"color: #333333;\">,<\/span> <span style=\"background-color: #fff0f0;\">\"Lagos\"<\/span><span style=\"color: #333333;\">),<\/span>\r\n\t<span style=\"background-color: #fff0f0;\">\"Jany@gmail.com\"<\/span><span style=\"color: #333333;\">);<\/span>\r\n\t\r\n   User user2 <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> User<span style=\"color: #333333;\">(<\/span>\r\n\t<span style=\"background-color: #fff0f0;\">\"u2\"<\/span><span style=\"color: #333333;\">,<\/span> \r\n\t<span style=\"background-color: #fff0f0;\">\"Jadon\"<\/span><span style=\"color: #333333;\">,<\/span> \r\n\t<span style=\"background-color: #fff0f0;\">\"Mills\"<\/span><span style=\"color: #333333;\">,<\/span>\r\n\t<span style=\"color: #008800; font-weight: bold;\">new<\/span> <span style=\"color: #0066bb; font-weight: bold;\">Location<\/span><span style=\"color: #333333;\">(<\/span><span style=\"background-color: #fff0f0;\">\"l2\"<\/span><span style=\"color: #333333;\">,<\/span> <span style=\"background-color: #fff0f0;\">\"Asaba\"<\/span><span style=\"color: #333333;\">),<\/span>\r\n\t\t\t<span style=\"background-color: #fff0f0;\">\"Jadon@gmail.com\"<\/span><span style=\"color: #333333;\">);<\/span>\r\n\t\r\n   <span style=\"color: #008800; font-weight: bold;\">private<\/span> List<span style=\"color: #333333;\">&lt;<\/span>User<span style=\"color: #333333;\">&gt;<\/span> users <span style=\"color: #333333;\">=<\/span> Arrays<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">asList<\/span><span style=\"color: #333333;\">(<\/span>user1<span style=\"color: #333333;\">,<\/span> user2<span style=\"color: #333333;\">);<\/span>\t\r\n\t\r\n   <span style=\"color: #008800; font-weight: bold;\">public<\/span> List<span style=\"color: #333333;\">&lt;<\/span>User<span style=\"color: #333333;\">&gt;<\/span> <span style=\"color: #0066bb; font-weight: bold;\">getAllUsers<\/span><span style=\"color: #333333;\">()<\/span> <span style=\"color: #333333;\">{<\/span>\r\n\t<span style=\"color: #008800; font-weight: bold;\">return<\/span> users<span style=\"color: #333333;\">;<\/span>\r\n   <span style=\"color: #333333;\">}<\/span>\r\n<span style=\"color: #333333;\">}<\/span>\r\n<\/pre>\n<p>Listing 1.1: The UserService Class<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Test the Application<\/strong><\/p>\n<p>To test the application, right-click on the the project and choose Run As &gt; Spring Boot Application<\/p>\n<p>Then visit localhost:8000\/users<\/p>\n<p>You will get a list of users in the json format. Now, everything work fine!<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h4><strong id=\"t4\">4. The Post Service and Controller<\/strong><\/h4>\n<p>Follow the same method to adjust the PostService and PostController files. The PostController File would be as shown below:<\/p>\n<p>&nbsp;<\/p>\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #008800; font-weight: bold;\">package<\/span> com<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">kindsonthegenius<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">social<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">post<\/span><span style=\"color: #333333;\">;<\/span>\r\n\r\n<span style=\"color: #008800; font-weight: bold;\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold;\">java.util.List<\/span><span style=\"color: #333333;\">;<\/span>\r\n\r\n<span style=\"color: #008800; font-weight: bold;\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold;\">org.springframework.beans.factory.annotation.Autowired<\/span><span style=\"color: #333333;\">;<\/span>\r\n<span style=\"color: #008800; font-weight: bold;\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold;\">org.springframework.web.bind.annotation.RequestMapping<\/span><span style=\"color: #333333;\">;<\/span>\r\n<span style=\"color: #008800; font-weight: bold;\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold;\">org.springframework.web.bind.annotation.RestController<\/span><span style=\"color: #333333;\">;<\/span>\r\n\r\n<span style=\"color: #555555; font-weight: bold;\">@RestController<\/span>\r\n<span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #008800; font-weight: bold;\">class<\/span> <span style=\"color: #bb0066; font-weight: bold;\">PostController<\/span> <span style=\"color: #333333;\">{<\/span>\r\n\t\r\n\t<span style=\"color: #555555; font-weight: bold;\">@Autowired<\/span>\r\n\t<span style=\"color: #008800; font-weight: bold;\">private<\/span> PostService postService<span style=\"color: #333333;\">;<\/span>\r\n\t\r\n\t<span style=\"color: #555555; font-weight: bold;\">@RequestMapping<\/span><span style=\"color: #333333;\">(<\/span>value <span style=\"color: #333333;\">=<\/span> <span style=\"background-color: #fff0f0;\">\"\/posts\"<\/span><span style=\"color: #333333;\">)<\/span>\r\n\t<span style=\"color: #008800; font-weight: bold;\">public<\/span> List<span style=\"color: #333333;\">&lt;<\/span>Post<span style=\"color: #333333;\">&gt;<\/span> <span style=\"color: #0066bb; font-weight: bold;\">getAllPosts<\/span><span style=\"color: #333333;\">()<\/span> <span style=\"color: #333333;\">{<\/span>\r\n\t\t\r\n\t\t<span style=\"color: #008800; font-weight: bold;\">return<\/span> postService<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">getAllPosts<\/span><span style=\"color: #333333;\">();<\/span>\r\n\t<span style=\"color: #333333;\">}<\/span>\r\n<span style=\"color: #333333;\">}<\/span>\r\n<\/pre>\n<p>Listing 1.2: Content of the PostConroller file<\/p>\n<p>&nbsp;<\/p>\n<p>Similarly, the content of PostService would be as shown below<\/p>\n<p>&nbsp;<\/p>\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #008800; font-weight: bold;\">package<\/span> com<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">kindsonthegenius<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">social<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">post<\/span><span style=\"color: #333333;\">;<\/span>\r\n\r\n<span style=\"color: #008800; font-weight: bold;\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold;\">java.util.Arrays<\/span><span style=\"color: #333333;\">;<\/span>\r\n<span style=\"color: #008800; font-weight: bold;\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold;\">java.util.List<\/span><span style=\"color: #333333;\">;<\/span>\r\n\r\n<span style=\"color: #008800; font-weight: bold;\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold;\">org.springframework.stereotype.Service<\/span><span style=\"color: #333333;\">;<\/span>\r\n\r\n<span style=\"color: #008800; font-weight: bold;\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold;\">com.kindsonthegenius.social.location.Location<\/span><span style=\"color: #333333;\">;<\/span>\r\n<span style=\"color: #008800; font-weight: bold;\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold;\">com.kindsonthegenius.social.user.User<\/span><span style=\"color: #333333;\">;<\/span>\r\n\r\n<span style=\"color: #555555; font-weight: bold;\">@Service<\/span>\r\n<span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #008800; font-weight: bold;\">class<\/span> <span style=\"color: #bb0066; font-weight: bold;\">PostService<\/span> <span style=\"color: #333333;\">{<\/span>\r\n\r\n   User user1 <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> User<span style=\"color: #333333;\">(<\/span>\r\n\t<span style=\"background-color: #fff0f0;\">\"u1\"<\/span><span style=\"color: #333333;\">,<\/span> \r\n\t<span style=\"background-color: #fff0f0;\">\"Jany\"<\/span><span style=\"color: #333333;\">,<\/span> \r\n\t<span style=\"background-color: #fff0f0;\">\"Lawrence\"<\/span><span style=\"color: #333333;\">,<\/span>\r\n\t<span style=\"color: #008800; font-weight: bold;\">new<\/span> <span style=\"color: #0066bb; font-weight: bold;\">Location<\/span><span style=\"color: #333333;\">(<\/span><span style=\"background-color: #fff0f0;\">\"l1\"<\/span><span style=\"color: #333333;\">,<\/span> <span style=\"background-color: #fff0f0;\">\"Lagos\"<\/span><span style=\"color: #333333;\">),<\/span>\r\n\t<span style=\"background-color: #fff0f0;\">\"Jany@gmail.com\"<\/span><span style=\"color: #333333;\">);<\/span>\r\n\t\r\n   User user2 <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> User<span style=\"color: #333333;\">(<\/span>\r\n\t<span style=\"background-color: #fff0f0;\">\"u2\"<\/span><span style=\"color: #333333;\">,<\/span> \r\n\t<span style=\"background-color: #fff0f0;\">\"Jadon\"<\/span><span style=\"color: #333333;\">,<\/span> \r\n\t<span style=\"background-color: #fff0f0;\">\"Mills\"<\/span><span style=\"color: #333333;\">,<\/span>\r\n\t<span style=\"color: #008800; font-weight: bold;\">new<\/span> <span style=\"color: #0066bb; font-weight: bold;\">Location<\/span><span style=\"color: #333333;\">(<\/span><span style=\"background-color: #fff0f0;\">\"l2\"<\/span><span style=\"color: #333333;\">,<\/span> <span style=\"background-color: #fff0f0;\">\"Asaba\"<\/span><span style=\"color: #333333;\">),<\/span>\r\n\t<span style=\"background-color: #fff0f0;\">\"Jadon@gmail.com\"<\/span><span style=\"color: #333333;\">);<\/span>\r\n\t\r\n   Post post1 <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> Post<span style=\"color: #333333;\">(<\/span>\r\n\t<span style=\"background-color: #fff0f0;\">\"p1\"<\/span><span style=\"color: #333333;\">,<\/span>\r\n\t<span style=\"background-color: #fff0f0;\">\"01-Jan-19\"<\/span><span style=\"color: #333333;\">,<\/span>\r\n\tuser1<span style=\"color: #333333;\">,<\/span>\r\n\t<span style=\"background-color: #fff0f0;\">\"Its good to love and be loved\"<\/span><span style=\"color: #333333;\">);<\/span>\r\n\t\r\n   Post post2 <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> Post<span style=\"color: #333333;\">(<\/span>\r\n\t<span style=\"background-color: #fff0f0;\">\"p2\"<\/span><span style=\"color: #333333;\">,<\/span>\r\n\t<span style=\"background-color: #fff0f0;\">\"02-Jan-19\"<\/span><span style=\"color: #333333;\">,<\/span>\r\n\tuser2<span style=\"color: #333333;\">,<\/span>\r\n\t<span style=\"background-color: #fff0f0;\">\"We all need someone\"<\/span><span style=\"color: #333333;\">);<\/span>\r\n\t\r\n   List<span style=\"color: #333333;\">&lt;<\/span>Post<span style=\"color: #333333;\">&gt;<\/span> posts <span style=\"color: #333333;\">=<\/span> Arrays<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">asList<\/span><span style=\"color: #333333;\">(<\/span>post1<span style=\"color: #333333;\">,<\/span> post2<span style=\"color: #333333;\">);<\/span>\r\n\t\r\n   <span style=\"color: #008800; font-weight: bold;\">public<\/span> List<span style=\"color: #333333;\">&lt;<\/span>Post<span style=\"color: #333333;\">&gt;<\/span> <span style=\"color: #0066bb; font-weight: bold;\">getAllPosts<\/span><span style=\"color: #333333;\">()<\/span> <span style=\"color: #333333;\">{<\/span>\r\n\t<span style=\"color: #008800; font-weight: bold;\">return<\/span> posts<span style=\"color: #333333;\">;<\/span>\r\n   <span style=\"color: #333333;\">}<\/span>\r\n\t\r\n<span style=\"color: #333333;\">}<\/span>\r\n<\/pre>\n<p>Listing 1.3: Content of the PostService class<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h4><strong id=\"t5\">5. The Location Service and Controller<\/strong><\/h4>\n<p>Finally, modify the LocationService and Location Controller files. You LocationController class would then be as shown below:<\/p>\n<p>&nbsp;<\/p>\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #008800; font-weight: bold;\">package<\/span> com<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">kindsonthegenius<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">social<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">location<\/span><span style=\"color: #333333;\">;<\/span>\r\n\r\n<span style=\"color: #008800; font-weight: bold;\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold;\">java.util.Arrays<\/span><span style=\"color: #333333;\">;<\/span>\r\n<span style=\"color: #008800; font-weight: bold;\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold;\">java.util.List<\/span><span style=\"color: #333333;\">;<\/span>\r\n\r\n<span style=\"color: #008800; font-weight: bold;\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold;\">org.springframework.beans.factory.annotation.Autowired<\/span><span style=\"color: #333333;\">;<\/span>\r\n<span style=\"color: #008800; font-weight: bold;\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold;\">org.springframework.web.bind.annotation.RequestMapping<\/span><span style=\"color: #333333;\">;<\/span>\r\n<span style=\"color: #008800; font-weight: bold;\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold;\">org.springframework.web.bind.annotation.RestController<\/span><span style=\"color: #333333;\">;<\/span>\r\n\r\n<span style=\"color: #555555; font-weight: bold;\">@RestController<\/span>\r\n<span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #008800; font-weight: bold;\">class<\/span> <span style=\"color: #bb0066; font-weight: bold;\">LocationController<\/span> <span style=\"color: #333333;\">{<\/span>\r\n\t\r\n   <span style=\"color: #555555; font-weight: bold;\">@Autowired<\/span>\r\n   <span style=\"color: #008800; font-weight: bold;\">private<\/span> LocationService locationService<span style=\"color: #333333;\">;<\/span>\r\n\t\r\n   <span style=\"color: #555555; font-weight: bold;\">@RequestMapping<\/span><span style=\"color: #333333;\">(<\/span>value <span style=\"color: #333333;\">=<\/span> <span style=\"background-color: #fff0f0;\">\"\/locations\"<\/span><span style=\"color: #333333;\">)<\/span>\r\n   <span style=\"color: #008800; font-weight: bold;\">public<\/span> List<span style=\"color: #333333;\">&lt;<\/span>Location<span style=\"color: #333333;\">&gt;<\/span> <span style=\"color: #0066bb; font-weight: bold;\">getAllLocations<\/span><span style=\"color: #333333;\">()<\/span> \r\n   <span style=\"color: #333333;\">{<\/span>\r\n\t<span style=\"color: #008800; font-weight: bold;\">return<\/span> locationService<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">getAllLocations<\/span><span style=\"color: #333333;\">();<\/span>\r\n   <span style=\"color: #333333;\">}<\/span>\t\t\r\n\r\n<span style=\"color: #333333;\">}<\/span>\r\n<\/pre>\n<p>Listing 1.4: Content of the LocationController class<\/p>\n<p>&nbsp;<\/p>\n<p>Similarly, the content of LocationService would be as shown below<\/p>\n<p>&nbsp;<\/p>\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #008800; font-weight: bold;\">package<\/span> com<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">kindsonthegenius<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">social<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">location<\/span><span style=\"color: #333333;\">;<\/span>\r\n\r\n<span style=\"color: #008800; font-weight: bold;\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold;\">java.util.ArrayList<\/span><span style=\"color: #333333;\">;<\/span>\r\n<span style=\"color: #008800; font-weight: bold;\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold;\">java.util.Arrays<\/span><span style=\"color: #333333;\">;<\/span>\r\n<span style=\"color: #008800; font-weight: bold;\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold;\">java.util.List<\/span><span style=\"color: #333333;\">;<\/span>\r\n<span style=\"color: #008800; font-weight: bold;\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold;\">java.util.Optional<\/span><span style=\"color: #333333;\">;<\/span>\r\n\r\n<span style=\"color: #008800; font-weight: bold;\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold;\">org.springframework.beans.factory.annotation.Autowired<\/span><span style=\"color: #333333;\">;<\/span>\r\n<span style=\"color: #008800; font-weight: bold;\">import<\/span> <span style=\"color: #0e84b5; font-weight: bold;\">org.springframework.stereotype.Service<\/span><span style=\"color: #333333;\">;<\/span>\r\n\r\n<span style=\"color: #555555; font-weight: bold;\">@Service<\/span>\r\n<span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #008800; font-weight: bold;\">class<\/span> <span style=\"color: #bb0066; font-weight: bold;\">LocationService<\/span> <span style=\"color: #333333;\">{<\/span>\r\n\t\r\n   Location location1 <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> Location<span style=\"color: #333333;\">(<\/span><span style=\"background-color: #fff0f0;\">\"l1\"<\/span><span style=\"color: #333333;\">,<\/span> <span style=\"background-color: #fff0f0;\">\"Lagos\"<\/span><span style=\"color: #333333;\">);<\/span>\r\n   Location location2 <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> Location<span style=\"color: #333333;\">(<\/span><span style=\"background-color: #fff0f0;\">\"l2\"<\/span><span style=\"color: #333333;\">,<\/span> <span style=\"background-color: #fff0f0;\">\"Asaba\"<\/span><span style=\"color: #333333;\">);<\/span>\r\n   Location location3 <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> Location<span style=\"color: #333333;\">(<\/span><span style=\"background-color: #fff0f0;\">\"l3\"<\/span><span style=\"color: #333333;\">,<\/span> <span style=\"background-color: #fff0f0;\">\"Budapest\"<\/span><span style=\"color: #333333;\">);<\/span>\t\r\n   \r\n   List<span style=\"color: #333333;\">&lt;<\/span>Location<span style=\"color: #333333;\">&gt;<\/span> locations <span style=\"color: #333333;\">=<\/span> Arrays<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">asList<\/span><span style=\"color: #333333;\">(<\/span>location1<span style=\"color: #333333;\">,<\/span> location2<span style=\"color: #333333;\">,<\/span> location3<span style=\"color: #333333;\">);<\/span>\r\n\t\r\n   <span style=\"color: #008800; font-weight: bold;\">public<\/span> List<span style=\"color: #333333;\">&lt;<\/span>Location<span style=\"color: #333333;\">&gt;<\/span> <span style=\"color: #0066bb; font-weight: bold;\">getAllLocations<\/span><span style=\"color: #333333;\">()<\/span> <span style=\"color: #333333;\">{<\/span>\r\n\t\t\r\n\t<span style=\"color: #008800; font-weight: bold;\">return<\/span> locations<span style=\"color: #333333;\">;<\/span>\r\n   <span style=\"color: #333333;\">}<\/span>\r\n\r\n<span style=\"color: #333333;\">}<\/span>\r\n<\/pre>\n<p>Listing 1.5: Content of the LocationService class<\/p>\n<p>&nbsp;<\/p>\n<p>Finally, go ahead to test the application.Access the following urls:<\/p>\n<p>http:\/\/localhost:8080\/users<\/p>\n<p>http:\/\/localhost:8080\/posts<\/p>\n<p>http:\/\/localhost:8080\/locations<\/p>\n<!-- AddThis Advanced Settings generic via filter on the_content --><!-- AddThis Share Buttons generic via filter on the_content -->","protected":false},"excerpt":{"rendered":"<p>We would learn about how to use the business services we created previously. We actually will move the logic from the controller to the business &hellip; <!-- AddThis Advanced Settings generic via filter on get_the_excerpt --><!-- AddThis Share Buttons generic via filter on get_the_excerpt --><\/p>\n","protected":false},"author":1,"featured_media":90,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[2],"tags":[],"class_list":["post-87","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-spring-boot-tutorials"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.6 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Spring Boot - Using the Business Service - Learn Spring Boot<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.kindsonthegenius.com\/spring-boot\/10-spring-boot-using-the-business-service\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Spring Boot - Using the Business Service - Learn Spring Boot\" \/>\n<meta property=\"og:description\" content=\"We would learn about how to use the business services we created previously. We actually will move the logic from the controller to the business &hellip;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.kindsonthegenius.com\/spring-boot\/10-spring-boot-using-the-business-service\/\" \/>\n<meta property=\"og:site_name\" content=\"Learn Spring Boot\" \/>\n<meta property=\"article:published_time\" content=\"2019-03-06T12:49:32+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-07-26T08:12:43+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.kindsonthegenius.com\/spring-boot\/wp-content\/uploads\/sites\/7\/2019\/03\/Using-the-Business-Service.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"781\" \/>\n\t<meta property=\"og:image:height\" content=\"451\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"kindsonthegenius\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"kindsonthegenius\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/10-spring-boot-using-the-business-service\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/10-spring-boot-using-the-business-service\\\/\"},\"author\":{\"name\":\"kindsonthegenius\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/#\\\/schema\\\/person\\\/7f8fc5792578d2ff54003fcebe6c46b5\"},\"headline\":\"Spring Boot &#8211; Using the Business Service\",\"datePublished\":\"2019-03-06T12:49:32+00:00\",\"dateModified\":\"2020-07-26T08:12:43+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/10-spring-boot-using-the-business-service\\\/\"},\"wordCount\":494,\"commentCount\":1,\"image\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/10-spring-boot-using-the-business-service\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/wp-content\\\/uploads\\\/sites\\\/7\\\/2019\\\/03\\\/Using-the-Business-Service.jpg\",\"articleSection\":[\"Spring Boot Tutorials\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/10-spring-boot-using-the-business-service\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/10-spring-boot-using-the-business-service\\\/\",\"url\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/10-spring-boot-using-the-business-service\\\/\",\"name\":\"Spring Boot - Using the Business Service - Learn Spring Boot\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/10-spring-boot-using-the-business-service\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/10-spring-boot-using-the-business-service\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/wp-content\\\/uploads\\\/sites\\\/7\\\/2019\\\/03\\\/Using-the-Business-Service.jpg\",\"datePublished\":\"2019-03-06T12:49:32+00:00\",\"dateModified\":\"2020-07-26T08:12:43+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/#\\\/schema\\\/person\\\/7f8fc5792578d2ff54003fcebe6c46b5\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/10-spring-boot-using-the-business-service\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/10-spring-boot-using-the-business-service\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/10-spring-boot-using-the-business-service\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/wp-content\\\/uploads\\\/sites\\\/7\\\/2019\\\/03\\\/Using-the-Business-Service.jpg\",\"contentUrl\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/wp-content\\\/uploads\\\/sites\\\/7\\\/2019\\\/03\\\/Using-the-Business-Service.jpg\",\"width\":781,\"height\":451},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/10-spring-boot-using-the-business-service\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Spring Boot &#8211; Using the Business Service\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/#website\",\"url\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/\",\"name\":\"Learn Spring Boot\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/#\\\/schema\\\/person\\\/7f8fc5792578d2ff54003fcebe6c46b5\",\"name\":\"kindsonthegenius\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/b9d710de456c3d85e5614c3a6992fa3d527425e2ab32b8bd5d85bfbaa235004b?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/b9d710de456c3d85e5614c3a6992fa3d527425e2ab32b8bd5d85bfbaa235004b?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/b9d710de456c3d85e5614c3a6992fa3d527425e2ab32b8bd5d85bfbaa235004b?s=96&d=mm&r=g\",\"caption\":\"kindsonthegenius\"},\"url\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/author\\\/kindsonthegenius-3\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Spring Boot - Using the Business Service - Learn Spring Boot","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.kindsonthegenius.com\/spring-boot\/10-spring-boot-using-the-business-service\/","og_locale":"en_US","og_type":"article","og_title":"Spring Boot - Using the Business Service - Learn Spring Boot","og_description":"We would learn about how to use the business services we created previously. We actually will move the logic from the controller to the business &hellip;","og_url":"https:\/\/www.kindsonthegenius.com\/spring-boot\/10-spring-boot-using-the-business-service\/","og_site_name":"Learn Spring Boot","article_published_time":"2019-03-06T12:49:32+00:00","article_modified_time":"2020-07-26T08:12:43+00:00","og_image":[{"width":781,"height":451,"url":"https:\/\/www.kindsonthegenius.com\/spring-boot\/wp-content\/uploads\/sites\/7\/2019\/03\/Using-the-Business-Service.jpg","type":"image\/jpeg"}],"author":"kindsonthegenius","twitter_card":"summary_large_image","twitter_misc":{"Written by":"kindsonthegenius","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.kindsonthegenius.com\/spring-boot\/10-spring-boot-using-the-business-service\/#article","isPartOf":{"@id":"https:\/\/www.kindsonthegenius.com\/spring-boot\/10-spring-boot-using-the-business-service\/"},"author":{"name":"kindsonthegenius","@id":"https:\/\/www.kindsonthegenius.com\/spring-boot\/#\/schema\/person\/7f8fc5792578d2ff54003fcebe6c46b5"},"headline":"Spring Boot &#8211; Using the Business Service","datePublished":"2019-03-06T12:49:32+00:00","dateModified":"2020-07-26T08:12:43+00:00","mainEntityOfPage":{"@id":"https:\/\/www.kindsonthegenius.com\/spring-boot\/10-spring-boot-using-the-business-service\/"},"wordCount":494,"commentCount":1,"image":{"@id":"https:\/\/www.kindsonthegenius.com\/spring-boot\/10-spring-boot-using-the-business-service\/#primaryimage"},"thumbnailUrl":"https:\/\/www.kindsonthegenius.com\/spring-boot\/wp-content\/uploads\/sites\/7\/2019\/03\/Using-the-Business-Service.jpg","articleSection":["Spring Boot Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.kindsonthegenius.com\/spring-boot\/10-spring-boot-using-the-business-service\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.kindsonthegenius.com\/spring-boot\/10-spring-boot-using-the-business-service\/","url":"https:\/\/www.kindsonthegenius.com\/spring-boot\/10-spring-boot-using-the-business-service\/","name":"Spring Boot - Using the Business Service - Learn Spring Boot","isPartOf":{"@id":"https:\/\/www.kindsonthegenius.com\/spring-boot\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.kindsonthegenius.com\/spring-boot\/10-spring-boot-using-the-business-service\/#primaryimage"},"image":{"@id":"https:\/\/www.kindsonthegenius.com\/spring-boot\/10-spring-boot-using-the-business-service\/#primaryimage"},"thumbnailUrl":"https:\/\/www.kindsonthegenius.com\/spring-boot\/wp-content\/uploads\/sites\/7\/2019\/03\/Using-the-Business-Service.jpg","datePublished":"2019-03-06T12:49:32+00:00","dateModified":"2020-07-26T08:12:43+00:00","author":{"@id":"https:\/\/www.kindsonthegenius.com\/spring-boot\/#\/schema\/person\/7f8fc5792578d2ff54003fcebe6c46b5"},"breadcrumb":{"@id":"https:\/\/www.kindsonthegenius.com\/spring-boot\/10-spring-boot-using-the-business-service\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.kindsonthegenius.com\/spring-boot\/10-spring-boot-using-the-business-service\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.kindsonthegenius.com\/spring-boot\/10-spring-boot-using-the-business-service\/#primaryimage","url":"https:\/\/www.kindsonthegenius.com\/spring-boot\/wp-content\/uploads\/sites\/7\/2019\/03\/Using-the-Business-Service.jpg","contentUrl":"https:\/\/www.kindsonthegenius.com\/spring-boot\/wp-content\/uploads\/sites\/7\/2019\/03\/Using-the-Business-Service.jpg","width":781,"height":451},{"@type":"BreadcrumbList","@id":"https:\/\/www.kindsonthegenius.com\/spring-boot\/10-spring-boot-using-the-business-service\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.kindsonthegenius.com\/spring-boot\/"},{"@type":"ListItem","position":2,"name":"Spring Boot &#8211; Using the Business Service"}]},{"@type":"WebSite","@id":"https:\/\/www.kindsonthegenius.com\/spring-boot\/#website","url":"https:\/\/www.kindsonthegenius.com\/spring-boot\/","name":"Learn Spring Boot","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.kindsonthegenius.com\/spring-boot\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.kindsonthegenius.com\/spring-boot\/#\/schema\/person\/7f8fc5792578d2ff54003fcebe6c46b5","name":"kindsonthegenius","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/b9d710de456c3d85e5614c3a6992fa3d527425e2ab32b8bd5d85bfbaa235004b?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/b9d710de456c3d85e5614c3a6992fa3d527425e2ab32b8bd5d85bfbaa235004b?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/b9d710de456c3d85e5614c3a6992fa3d527425e2ab32b8bd5d85bfbaa235004b?s=96&d=mm&r=g","caption":"kindsonthegenius"},"url":"https:\/\/www.kindsonthegenius.com\/spring-boot\/author\/kindsonthegenius-3\/"}]}},"_links":{"self":[{"href":"https:\/\/www.kindsonthegenius.com\/spring-boot\/wp-json\/wp\/v2\/posts\/87","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kindsonthegenius.com\/spring-boot\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kindsonthegenius.com\/spring-boot\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kindsonthegenius.com\/spring-boot\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kindsonthegenius.com\/spring-boot\/wp-json\/wp\/v2\/comments?post=87"}],"version-history":[{"count":9,"href":"https:\/\/www.kindsonthegenius.com\/spring-boot\/wp-json\/wp\/v2\/posts\/87\/revisions"}],"predecessor-version":[{"id":231,"href":"https:\/\/www.kindsonthegenius.com\/spring-boot\/wp-json\/wp\/v2\/posts\/87\/revisions\/231"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.kindsonthegenius.com\/spring-boot\/wp-json\/wp\/v2\/media\/90"}],"wp:attachment":[{"href":"https:\/\/www.kindsonthegenius.com\/spring-boot\/wp-json\/wp\/v2\/media?parent=87"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kindsonthegenius.com\/spring-boot\/wp-json\/wp\/v2\/categories?post=87"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kindsonthegenius.com\/spring-boot\/wp-json\/wp\/v2\/tags?post=87"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}