{"id":97,"date":"2019-03-07T06:55:34","date_gmt":"2019-03-07T06:55:34","guid":{"rendered":"https:\/\/www.kindsonthegenius.com\/spring-boot\/?p=97"},"modified":"2020-07-26T08:13:13","modified_gmt":"2020-07-26T08:13:13","slug":"11-spring-boot-get-item-by-id","status":"publish","type":"post","link":"https:\/\/www.kindsonthegenius.com\/spring-boot\/11-spring-boot-get-item-by-id\/","title":{"rendered":"Spring Boot &#8211; Get Item by Id"},"content":{"rendered":"<p>In this chapter, we are going to write the methods to get resources by Id.<\/p>\n<p>Remember that in the <a href=\"https:\/\/www.kindsonthegenius.com\/spring-boot\/09-spring-boot-write-get-methods\/\">previous chapter(Write GET Methods)<\/a>, we wrote methods, to get all resources. For example, getAllUsers, getAllPosts and getAllLocation. But this time we would write methods for getUser, getPost and getLocation.<\/p>\n<p>This methods would take parameter, which is the id of the item to get.<\/p>\n<p>&nbsp;<\/p>\n<ol>\n<li><a href=\"#t1\">Get a Single User<\/a><\/li>\n<li><a href=\"#t2\">Get a Single Post<\/a><\/li>\n<li><a href=\"#t3\">Get a Single Location<\/a><\/li>\n<li>Test the Application<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<h4><strong id=\"t1\">1. Get a Single User<\/strong><\/h4>\n<p>So this method would be written in the UserService file. We call this method GetUser. On way to do this is to loop through the user and find a match for the passed in id parameter. But in this tutorial we would use the stream API.<\/p>\n<p>The method is as shown below:<\/p>\n<p>&nbsp;<\/p>\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #008800; font-weight: bold;\">public<\/span> User <span style=\"color: #0066bb; font-weight: bold;\">getUser<\/span><span style=\"color: #333333;\">(<\/span>String id<span style=\"color: #333333;\">)<\/span> <span style=\"color: #333333;\">{<\/span>\r\n    User user <span style=\"color: #333333;\">=<\/span> users<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">stream<\/span><span style=\"color: #333333;\">()<\/span>\r\n\t\t<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">filter<\/span><span style=\"color: #333333;\">(<\/span>t <span style=\"color: #333333;\">-&gt; id<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">equals<\/span><span style=\"color: #333333;\">(<\/span>t<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">getId<\/span><span style=\"color: #333333;\">()))<\/span>\r\n\t\t<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">findFirst<\/span><span style=\"color: #333333;\">()<\/span>\r\n\t\t<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">orElse<\/span><span style=\"color: #333333;\">(<\/span><span style=\"color: #008800; font-weight: bold;\">null<\/span><span style=\"color: #333333;\">);<\/span>\r\n\t\t\r\n    <span style=\"color: #008800; font-weight: bold;\">return<\/span> user<span style=\"color: #333333;\">;<\/span>\r\n<span style=\"color: #333333;\">}<\/span>\r\n<\/pre>\n<p>Listing 1.0: getUser Method using Stream API<\/p>\n<p>&nbsp;<\/p>\n<p>Now, we go to the UserController. We&#8217;ll write a method that handles a request to <em>\/User\/id<\/em>. For example the request to <em>\/User\/u1<\/em> should return the user with id of u1. Similarly request to <em>\/User\/u2<\/em> should return the user with id of u2. And so on.<\/p>\n<p>The method is shown below<\/p>\n<p>&nbsp;<\/p>\n<p><!-- HTML generated using hilite.me --><\/p>\n<pre style=\"margin: 0; line-height: 125%;\"><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\/{id}\"<\/span><span style=\"color: #333333;\">)<\/span>\r\n<span style=\"color: #008800; font-weight: bold;\">public<\/span> User <span style=\"color: #0066bb; font-weight: bold;\">getUser<\/span><span style=\"color: #333333;\">(<\/span><span style=\"color: #555555; font-weight: bold;\">@PathVariable<\/span> String id<span style=\"color: #333333;\">)<\/span> <span style=\"color: #333333;\">{<\/span>\r\n    <span style=\"color: #008800; font-weight: bold;\">return<\/span> userService<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">getUser<\/span><span style=\"color: #333333;\">(<\/span>id<span style=\"color: #333333;\">);<\/span>\r\n<span style=\"color: #333333;\">}<\/span>\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h4><strong id=\"t2\">2. Get a Single Post<\/strong><\/h4>\n<p>We then write the methods to return a single post. It follows the same pattern as returning a single user.<\/p>\n<p>The method for the PostService is given below;<\/p>\n<p>&nbsp;<\/p>\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #008800; font-weight: bold;\">public<\/span> Post <span style=\"color: #0066bb; font-weight: bold;\">getPost<\/span><span style=\"color: #333333;\">(<\/span>String id<span style=\"color: #333333;\">)<\/span> <span style=\"color: #333333;\">{<\/span>\r\n    \tPost post <span style=\"color: #333333;\">=<\/span> posts<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">stream<\/span><span style=\"color: #333333;\">()<\/span>\r\n\t\t<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">filter<\/span><span style=\"color: #333333;\">(<\/span>t <span style=\"color: #333333;\">-&gt;<\/span> id<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">equals<\/span><span style=\"color: #333333;\">(<\/span>t<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">getId<\/span><span style=\"color: #333333;\">()))<\/span>\r\n\t\t<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">findFirst<\/span><span style=\"color: #333333;\">()<\/span>\r\n\t\t<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">orElse<\/span><span style=\"color: #333333;\">(<\/span><span style=\"color: #008800; font-weight: bold;\">null<\/span><span style=\"color: #333333;\">);<\/span>\r\n\t\t\r\n\t<span style=\"color: #008800; font-weight: bold;\">return<\/span> post<span style=\"color: #333333;\">;<\/span>\r\n<span style=\"color: #333333;\">}<\/span>\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>The method for the PostController is given below as well<\/p>\n<p>&nbsp;<\/p>\n<p><!-- HTML generated using hilite.me --><\/p>\n<pre style=\"margin: 0; line-height: 125%;\"><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\/{id}\"<\/span><span style=\"color: #333333;\">)<\/span>\r\n<span style=\"color: #008800; font-weight: bold;\">public<\/span> Post <span style=\"color: #0066bb; font-weight: bold;\">getPost<\/span><span style=\"color: #333333;\">(<\/span><span style=\"color: #555555; font-weight: bold;\">@PathVariable<\/span> String id<span style=\"color: #333333;\">)<\/span> <span style=\"color: #333333;\">{<\/span>\r\n    <span style=\"color: #008800; font-weight: bold;\">return<\/span> postService<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">getPost<\/span><span style=\"color: #333333;\">(<\/span> id<span style=\"color: #333333;\">);<\/span>\r\n<span style=\"color: #333333;\">}<\/span>\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h4><strong id=\"t3\">3. Get a Single Location<\/strong><\/h4>\n<p>In the same way, we write the getLocation method for the LocationService and LocationController files.<\/p>\n<p>&nbsp;<\/p>\n<p>Put the code below in the LocationService class<\/p>\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #008800; font-weight: bold;\">public<\/span> Location <span style=\"color: #0066bb; font-weight: bold;\">getLocation<\/span><span style=\"color: #333333;\">(<\/span>String id<span style=\"color: #333333;\">)<\/span> <span style=\"color: #333333;\">{<\/span>\r\n    Location location <span style=\"color: #333333;\">=<\/span> locations<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">stream<\/span><span style=\"color: #333333;\">()<\/span>\r\n\t<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">filter<\/span><span style=\"color: #333333;\">(<\/span>t <span style=\"color: #333333;\">-&gt;<\/span> id<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">equals<\/span><span style=\"color: #333333;\">(<\/span>t<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">getId<\/span><span style=\"color: #333333;\">()))<\/span>\r\n\t<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">findFirst<\/span><span style=\"color: #333333;\">()<\/span>\r\n\t<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">orElse<\/span><span style=\"color: #333333;\">(<\/span><span style=\"color: #008800; font-weight: bold;\">null<\/span><span style=\"color: #333333;\">);<\/span>\r\n\t\t\r\n    <span style=\"color: #008800; font-weight: bold;\">return<\/span> location<span style=\"color: #333333;\">;<\/span>\r\n<span style=\"color: #333333;\">}<\/span>\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>Put the code below in the LocationController class<\/p>\n<p><!-- HTML generated using hilite.me --><\/p>\n<pre style=\"margin: 0; line-height: 125%;\"><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\/{id}\"<\/span><span style=\"color: #333333;\">)<\/span>\r\n<span style=\"color: #008800; font-weight: bold;\">public<\/span> Location <span style=\"color: #0066bb; font-weight: bold;\">getLocation<\/span><span style=\"color: #333333;\">(<\/span><span style=\"color: #555555; font-weight: bold;\">@PathVariable<\/span> String id<span style=\"color: #333333;\">)<\/span> <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;\">getLocation<\/span><span style=\"color: #333333;\">(<\/span>id<span style=\"color: #333333;\">);<\/span>\r\n<span style=\"color: #333333;\">}<\/span>\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h4><strong>4. Test the Application<\/strong><\/h4>\n<p>Now, it&#8217;s time to test the application.<\/p>\n<p>So right-click on the application. Choose Run As &gt; Spring Boot Application<\/p>\n<p>Then Open the browser and visit the following urls:<\/p>\n<ul>\n<li>http:\/\/localhost:8080\/users\/u1<\/li>\n<li>http:\/\/localhost:8080\/posts\/p1<\/li>\n<li>http:\/\/localhost:8080\/locations\/l1<\/li>\n<\/ul>\n<p>If you have any challenges, please mention it in the comment box below.<\/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>In this chapter, we are going to write the methods to get resources by Id. Remember that in the previous chapter(Write GET Methods), we wrote &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":98,"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-97","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.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Spring Boot - Get Item by Id - 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\/11-spring-boot-get-item-by-id\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Spring Boot - Get Item by Id - Learn Spring Boot\" \/>\n<meta property=\"og:description\" content=\"In this chapter, we are going to write the methods to get resources by Id. Remember that in the previous chapter(Write GET Methods), we wrote &hellip;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.kindsonthegenius.com\/spring-boot\/11-spring-boot-get-item-by-id\/\" \/>\n<meta property=\"og:site_name\" content=\"Learn Spring Boot\" \/>\n<meta property=\"article:published_time\" content=\"2019-03-07T06:55:34+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-07-26T08:13:13+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.kindsonthegenius.com\/spring-boot\/wp-content\/uploads\/sites\/7\/2019\/03\/Get-Resource-By-ID.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=\"2 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\\\/11-spring-boot-get-item-by-id\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/11-spring-boot-get-item-by-id\\\/\"},\"author\":{\"name\":\"kindsonthegenius\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/#\\\/schema\\\/person\\\/7f8fc5792578d2ff54003fcebe6c46b5\"},\"headline\":\"Spring Boot &#8211; Get Item by Id\",\"datePublished\":\"2019-03-07T06:55:34+00:00\",\"dateModified\":\"2020-07-26T08:13:13+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/11-spring-boot-get-item-by-id\\\/\"},\"wordCount\":351,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/11-spring-boot-get-item-by-id\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/wp-content\\\/uploads\\\/sites\\\/7\\\/2019\\\/03\\\/Get-Resource-By-ID.jpg\",\"articleSection\":[\"Spring Boot Tutorials\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/11-spring-boot-get-item-by-id\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/11-spring-boot-get-item-by-id\\\/\",\"url\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/11-spring-boot-get-item-by-id\\\/\",\"name\":\"Spring Boot - Get Item by Id - Learn Spring Boot\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/11-spring-boot-get-item-by-id\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/11-spring-boot-get-item-by-id\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/wp-content\\\/uploads\\\/sites\\\/7\\\/2019\\\/03\\\/Get-Resource-By-ID.jpg\",\"datePublished\":\"2019-03-07T06:55:34+00:00\",\"dateModified\":\"2020-07-26T08:13:13+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/#\\\/schema\\\/person\\\/7f8fc5792578d2ff54003fcebe6c46b5\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/11-spring-boot-get-item-by-id\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/11-spring-boot-get-item-by-id\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/11-spring-boot-get-item-by-id\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/wp-content\\\/uploads\\\/sites\\\/7\\\/2019\\\/03\\\/Get-Resource-By-ID.jpg\",\"contentUrl\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/wp-content\\\/uploads\\\/sites\\\/7\\\/2019\\\/03\\\/Get-Resource-By-ID.jpg\",\"width\":781,\"height\":451},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/11-spring-boot-get-item-by-id\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Spring Boot &#8211; Get Item by Id\"}]},{\"@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 - Get Item by Id - 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\/11-spring-boot-get-item-by-id\/","og_locale":"en_US","og_type":"article","og_title":"Spring Boot - Get Item by Id - Learn Spring Boot","og_description":"In this chapter, we are going to write the methods to get resources by Id. Remember that in the previous chapter(Write GET Methods), we wrote &hellip;","og_url":"https:\/\/www.kindsonthegenius.com\/spring-boot\/11-spring-boot-get-item-by-id\/","og_site_name":"Learn Spring Boot","article_published_time":"2019-03-07T06:55:34+00:00","article_modified_time":"2020-07-26T08:13:13+00:00","og_image":[{"width":781,"height":451,"url":"https:\/\/www.kindsonthegenius.com\/spring-boot\/wp-content\/uploads\/sites\/7\/2019\/03\/Get-Resource-By-ID.jpg","type":"image\/jpeg"}],"author":"kindsonthegenius","twitter_card":"summary_large_image","twitter_misc":{"Written by":"kindsonthegenius","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.kindsonthegenius.com\/spring-boot\/11-spring-boot-get-item-by-id\/#article","isPartOf":{"@id":"https:\/\/www.kindsonthegenius.com\/spring-boot\/11-spring-boot-get-item-by-id\/"},"author":{"name":"kindsonthegenius","@id":"https:\/\/www.kindsonthegenius.com\/spring-boot\/#\/schema\/person\/7f8fc5792578d2ff54003fcebe6c46b5"},"headline":"Spring Boot &#8211; Get Item by Id","datePublished":"2019-03-07T06:55:34+00:00","dateModified":"2020-07-26T08:13:13+00:00","mainEntityOfPage":{"@id":"https:\/\/www.kindsonthegenius.com\/spring-boot\/11-spring-boot-get-item-by-id\/"},"wordCount":351,"commentCount":0,"image":{"@id":"https:\/\/www.kindsonthegenius.com\/spring-boot\/11-spring-boot-get-item-by-id\/#primaryimage"},"thumbnailUrl":"https:\/\/www.kindsonthegenius.com\/spring-boot\/wp-content\/uploads\/sites\/7\/2019\/03\/Get-Resource-By-ID.jpg","articleSection":["Spring Boot Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.kindsonthegenius.com\/spring-boot\/11-spring-boot-get-item-by-id\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.kindsonthegenius.com\/spring-boot\/11-spring-boot-get-item-by-id\/","url":"https:\/\/www.kindsonthegenius.com\/spring-boot\/11-spring-boot-get-item-by-id\/","name":"Spring Boot - Get Item by Id - Learn Spring Boot","isPartOf":{"@id":"https:\/\/www.kindsonthegenius.com\/spring-boot\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.kindsonthegenius.com\/spring-boot\/11-spring-boot-get-item-by-id\/#primaryimage"},"image":{"@id":"https:\/\/www.kindsonthegenius.com\/spring-boot\/11-spring-boot-get-item-by-id\/#primaryimage"},"thumbnailUrl":"https:\/\/www.kindsonthegenius.com\/spring-boot\/wp-content\/uploads\/sites\/7\/2019\/03\/Get-Resource-By-ID.jpg","datePublished":"2019-03-07T06:55:34+00:00","dateModified":"2020-07-26T08:13:13+00:00","author":{"@id":"https:\/\/www.kindsonthegenius.com\/spring-boot\/#\/schema\/person\/7f8fc5792578d2ff54003fcebe6c46b5"},"breadcrumb":{"@id":"https:\/\/www.kindsonthegenius.com\/spring-boot\/11-spring-boot-get-item-by-id\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.kindsonthegenius.com\/spring-boot\/11-spring-boot-get-item-by-id\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.kindsonthegenius.com\/spring-boot\/11-spring-boot-get-item-by-id\/#primaryimage","url":"https:\/\/www.kindsonthegenius.com\/spring-boot\/wp-content\/uploads\/sites\/7\/2019\/03\/Get-Resource-By-ID.jpg","contentUrl":"https:\/\/www.kindsonthegenius.com\/spring-boot\/wp-content\/uploads\/sites\/7\/2019\/03\/Get-Resource-By-ID.jpg","width":781,"height":451},{"@type":"BreadcrumbList","@id":"https:\/\/www.kindsonthegenius.com\/spring-boot\/11-spring-boot-get-item-by-id\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.kindsonthegenius.com\/spring-boot\/"},{"@type":"ListItem","position":2,"name":"Spring Boot &#8211; Get Item by Id"}]},{"@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\/97","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=97"}],"version-history":[{"count":4,"href":"https:\/\/www.kindsonthegenius.com\/spring-boot\/wp-json\/wp\/v2\/posts\/97\/revisions"}],"predecessor-version":[{"id":233,"href":"https:\/\/www.kindsonthegenius.com\/spring-boot\/wp-json\/wp\/v2\/posts\/97\/revisions\/233"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.kindsonthegenius.com\/spring-boot\/wp-json\/wp\/v2\/media\/98"}],"wp:attachment":[{"href":"https:\/\/www.kindsonthegenius.com\/spring-boot\/wp-json\/wp\/v2\/media?parent=97"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kindsonthegenius.com\/spring-boot\/wp-json\/wp\/v2\/categories?post=97"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kindsonthegenius.com\/spring-boot\/wp-json\/wp\/v2\/tags?post=97"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}