{"id":103,"date":"2022-06-10T15:20:51","date_gmt":"2022-06-10T15:20:51","guid":{"rendered":"https:\/\/valerio.nu\/?p=103"},"modified":"2022-07-22T09:32:34","modified_gmt":"2022-07-22T09:32:34","slug":"create-a-spring-boot-project-in-vs-code","status":"publish","type":"post","link":"https:\/\/valerio.nu\/index.php\/2022\/06\/10\/create-a-spring-boot-project-in-vs-code\/","title":{"rendered":"Create a spring-boot project in Visual Studio Code"},"content":{"rendered":"\n<p>In this tutorial we show how to create a new spring-boot project in Visual Studio Code using a wizard. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Spring Initializr built-in<\/h2>\n\n\n\n<p>The way we would normally create a new Spring boot project is to open the <a href=\"https:\/\/start.spring.io\/\" target=\"_blank\" rel=\"noreferrer noopener\">Spring Initializr<\/a> in a browser, input a few parameters, download the project and import it in our IDE of choice. <\/p>\n\n\n\n<p>With Visual Studio Code the process is much simpler as Spring Initializr&#8217;s functionality is wrapped in the extensions that we installed in <a href=\"https:\/\/valerio.nu\/index.php\/2022\/05\/14\/setup-java-in-visual-studio-code\/\">the first article of this series<\/a>.<\/p>\n\n\n\n<figure class=\"wp-block-video\"><video height=\"720\" style=\"aspect-ratio: 1280 \/ 720;\" width=\"1280\" controls src=\"https:\/\/valerio.nu\/wp-content\/uploads\/2022\/06\/create-spring-boot-vs-code.mp4\"><\/video><\/figure>\n\n\n\n<p>All it took was a few clicks and our new project is ready to build in Maven. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">REST endpoint<\/h2>\n\n\n\n<p>Now let&#8217;s add a simple REST endpoint to our project. <\/p>\n\n\n\n<p>To keep things simple we go for a GET with two text parameters, needle and haystack. <\/p>\n\n\n\n<p>The annotation @GetMapping isn&#8217;t contained in the libraries that we imported so it breaks the project immediately. That is to be expected, this annotation is contained in the <a href=\"https:\/\/jar-download.com\/artifacts\/org.springframework\/spring-web\" target=\"_blank\" rel=\"noreferrer noopener\">spring-web<\/a> artifact so we need to import it in our pom.xml file. <\/p>\n\n\n\n<p>Here we are clearly missing the IntelliJ IDEA functionality to guess which artifact we need to import and find a way to solve the issue for us. Instead, we are forced to: leave the editor, search on the web to which artifact the annotation belongs to and add that artifact manually to our project. <\/p>\n\n\n\n<p>IntelliJ would have solved this for us in one click so it&#8217;s quite underwhelming that VS Code doesn&#8217;t have a similar functionality. <\/p>\n\n\n\n<figure class=\"wp-block-video\"><video height=\"1040\" style=\"aspect-ratio: 1920 \/ 1040;\" width=\"1920\" controls src=\"https:\/\/valerio.nu\/wp-content\/uploads\/2022\/06\/HaystackApplication.java-haystack-Visual-Studio-Code-2022-06-10-16-59-06.mp4\"><\/video><\/figure>\n\n\n\n<p>Now we are able to build our application that contains a simple REST endpoint. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Start-up the spring-boot application<\/h2>\n\n\n\n<p>What happens if we try to run our application? <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mvn spring-boot:run<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-video\"><video height=\"1040\" style=\"aspect-ratio: 1920 \/ 1040;\" width=\"1920\" controls src=\"https:\/\/valerio.nu\/wp-content\/uploads\/2022\/06\/HaystackController.java-haystack-Visual-Studio-Code-2022-06-10-17-07-29.mp4\"><\/video><\/figure>\n\n\n\n<p>The application starts successfully but terminates immediately. <\/p>\n\n\n\n<p>Again, we&#8217;re missing an important dependency in our pom.xml file but VS Code doesn&#8217;t know and doesn&#8217;t help. <\/p>\n\n\n\n<p>The missing dependency is of course the following: <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;dependency&gt;\n    &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;\n    &lt;artifactId&gt;spring-boot-starter-web&lt;\/artifactId&gt;\n&lt;\/dependency&gt;<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-video\"><video height=\"1040\" style=\"aspect-ratio: 1920 \/ 1040;\" width=\"1920\" controls src=\"https:\/\/valerio.nu\/wp-content\/uploads\/2022\/06\/\u25cf-pom.xml-haystack-Visual-Studio-Code-2022-06-10-17-11-30-1.mp4\"><\/video><\/figure>\n\n\n\n<p>Once we add the correct dependency and re-run the Maven command, our application is finally up-and-running and ready to receive requests. <\/p>\n\n\n\n<p>In this tutorial we discussed how to create a new spring-boot project in Visual Studio Code using Spring Initializr, we setup a controller class and create a simple REST endpoint. Finally, we build and start-up our application after importing the correct dependencies. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial we show how to create a new spring-boot project in Visual Studio Code using a wizard. Spring Initializr built-in The way we [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11,16],"tags":[],"class_list":["post-103","post","type-post","status-publish","format-standard","hentry","category-java","category-vscode"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Create a spring-boot project in Visual Studio Code - Andy&#039;s blog \u2935\ufe0f<\/title>\n<meta name=\"description\" content=\"In this tutorial we show how to create a new spring-boot project in Visual Studio Code using a wizard.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/valerio.nu\/index.php\/2022\/06\/10\/create-a-spring-boot-project-in-vs-code\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Create a spring-boot project in Visual Studio Code - Andy&#039;s blog \u2935\ufe0f\" \/>\n<meta property=\"og:description\" content=\"In this tutorial we show how to create a new spring-boot project in Visual Studio Code using a wizard.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/valerio.nu\/index.php\/2022\/06\/10\/create-a-spring-boot-project-in-vs-code\/\" \/>\n<meta property=\"og:site_name\" content=\"Andy&#039;s blog \u2935\ufe0f\" \/>\n<meta property=\"article:published_time\" content=\"2022-06-10T15:20:51+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-07-22T09:32:34+00:00\" \/>\n<meta name=\"author\" content=\"andy\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"andy\" \/>\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:\\\/\\\/valerio.nu\\\/index.php\\\/2022\\\/06\\\/10\\\/create-a-spring-boot-project-in-vs-code\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/valerio.nu\\\/index.php\\\/2022\\\/06\\\/10\\\/create-a-spring-boot-project-in-vs-code\\\/\"},\"author\":{\"name\":\"andy\",\"@id\":\"https:\\\/\\\/valerio.nu\\\/#\\\/schema\\\/person\\\/da69cc3da309893b0d3bc8fcef75f128\"},\"headline\":\"Create a spring-boot project in Visual Studio Code\",\"datePublished\":\"2022-06-10T15:20:51+00:00\",\"dateModified\":\"2022-07-22T09:32:34+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/valerio.nu\\\/index.php\\\/2022\\\/06\\\/10\\\/create-a-spring-boot-project-in-vs-code\\\/\"},\"wordCount\":379,\"commentCount\":0,\"articleSection\":[\"Java\",\"Visual Studio Code\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/valerio.nu\\\/index.php\\\/2022\\\/06\\\/10\\\/create-a-spring-boot-project-in-vs-code\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/valerio.nu\\\/index.php\\\/2022\\\/06\\\/10\\\/create-a-spring-boot-project-in-vs-code\\\/\",\"url\":\"https:\\\/\\\/valerio.nu\\\/index.php\\\/2022\\\/06\\\/10\\\/create-a-spring-boot-project-in-vs-code\\\/\",\"name\":\"Create a spring-boot project in Visual Studio Code - Andy&#039;s blog \u2935\ufe0f\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/valerio.nu\\\/#website\"},\"datePublished\":\"2022-06-10T15:20:51+00:00\",\"dateModified\":\"2022-07-22T09:32:34+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/valerio.nu\\\/#\\\/schema\\\/person\\\/da69cc3da309893b0d3bc8fcef75f128\"},\"description\":\"In this tutorial we show how to create a new spring-boot project in Visual Studio Code using a wizard.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/valerio.nu\\\/index.php\\\/2022\\\/06\\\/10\\\/create-a-spring-boot-project-in-vs-code\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/valerio.nu\\\/index.php\\\/2022\\\/06\\\/10\\\/create-a-spring-boot-project-in-vs-code\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/valerio.nu\\\/index.php\\\/2022\\\/06\\\/10\\\/create-a-spring-boot-project-in-vs-code\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/valerio.nu\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Create a spring-boot project in Visual Studio Code\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/valerio.nu\\\/#website\",\"url\":\"https:\\\/\\\/valerio.nu\\\/\",\"name\":\"Andy&#039;s blog \u2935\ufe0f\",\"description\":\"Abandon all hope, ye who enter here\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/valerio.nu\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/valerio.nu\\\/#\\\/schema\\\/person\\\/da69cc3da309893b0d3bc8fcef75f128\",\"name\":\"andy\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4852a025c6250c852814d4017f646677730a23c1ec14eb5ca36b69dcce5135a5?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4852a025c6250c852814d4017f646677730a23c1ec14eb5ca36b69dcce5135a5?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4852a025c6250c852814d4017f646677730a23c1ec14eb5ca36b69dcce5135a5?s=96&d=mm&r=g\",\"caption\":\"andy\"},\"sameAs\":[\"https:\\\/\\\/valerio.nu\"],\"url\":\"https:\\\/\\\/valerio.nu\\\/index.php\\\/author\\\/giuseppe\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Create a spring-boot project in Visual Studio Code - Andy&#039;s blog \u2935\ufe0f","description":"In this tutorial we show how to create a new spring-boot project in Visual Studio Code using a wizard.","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:\/\/valerio.nu\/index.php\/2022\/06\/10\/create-a-spring-boot-project-in-vs-code\/","og_locale":"en_US","og_type":"article","og_title":"Create a spring-boot project in Visual Studio Code - Andy&#039;s blog \u2935\ufe0f","og_description":"In this tutorial we show how to create a new spring-boot project in Visual Studio Code using a wizard.","og_url":"https:\/\/valerio.nu\/index.php\/2022\/06\/10\/create-a-spring-boot-project-in-vs-code\/","og_site_name":"Andy&#039;s blog \u2935\ufe0f","article_published_time":"2022-06-10T15:20:51+00:00","article_modified_time":"2022-07-22T09:32:34+00:00","author":"andy","twitter_card":"summary_large_image","twitter_misc":{"Written by":"andy","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/valerio.nu\/index.php\/2022\/06\/10\/create-a-spring-boot-project-in-vs-code\/#article","isPartOf":{"@id":"https:\/\/valerio.nu\/index.php\/2022\/06\/10\/create-a-spring-boot-project-in-vs-code\/"},"author":{"name":"andy","@id":"https:\/\/valerio.nu\/#\/schema\/person\/da69cc3da309893b0d3bc8fcef75f128"},"headline":"Create a spring-boot project in Visual Studio Code","datePublished":"2022-06-10T15:20:51+00:00","dateModified":"2022-07-22T09:32:34+00:00","mainEntityOfPage":{"@id":"https:\/\/valerio.nu\/index.php\/2022\/06\/10\/create-a-spring-boot-project-in-vs-code\/"},"wordCount":379,"commentCount":0,"articleSection":["Java","Visual Studio Code"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/valerio.nu\/index.php\/2022\/06\/10\/create-a-spring-boot-project-in-vs-code\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/valerio.nu\/index.php\/2022\/06\/10\/create-a-spring-boot-project-in-vs-code\/","url":"https:\/\/valerio.nu\/index.php\/2022\/06\/10\/create-a-spring-boot-project-in-vs-code\/","name":"Create a spring-boot project in Visual Studio Code - Andy&#039;s blog \u2935\ufe0f","isPartOf":{"@id":"https:\/\/valerio.nu\/#website"},"datePublished":"2022-06-10T15:20:51+00:00","dateModified":"2022-07-22T09:32:34+00:00","author":{"@id":"https:\/\/valerio.nu\/#\/schema\/person\/da69cc3da309893b0d3bc8fcef75f128"},"description":"In this tutorial we show how to create a new spring-boot project in Visual Studio Code using a wizard.","breadcrumb":{"@id":"https:\/\/valerio.nu\/index.php\/2022\/06\/10\/create-a-spring-boot-project-in-vs-code\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/valerio.nu\/index.php\/2022\/06\/10\/create-a-spring-boot-project-in-vs-code\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/valerio.nu\/index.php\/2022\/06\/10\/create-a-spring-boot-project-in-vs-code\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/valerio.nu\/"},{"@type":"ListItem","position":2,"name":"Create a spring-boot project in Visual Studio Code"}]},{"@type":"WebSite","@id":"https:\/\/valerio.nu\/#website","url":"https:\/\/valerio.nu\/","name":"Andy&#039;s blog \u2935\ufe0f","description":"Abandon all hope, ye who enter here","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/valerio.nu\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/valerio.nu\/#\/schema\/person\/da69cc3da309893b0d3bc8fcef75f128","name":"andy","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/4852a025c6250c852814d4017f646677730a23c1ec14eb5ca36b69dcce5135a5?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/4852a025c6250c852814d4017f646677730a23c1ec14eb5ca36b69dcce5135a5?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4852a025c6250c852814d4017f646677730a23c1ec14eb5ca36b69dcce5135a5?s=96&d=mm&r=g","caption":"andy"},"sameAs":["https:\/\/valerio.nu"],"url":"https:\/\/valerio.nu\/index.php\/author\/giuseppe\/"}]}},"_links":{"self":[{"href":"https:\/\/valerio.nu\/index.php\/wp-json\/wp\/v2\/posts\/103","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/valerio.nu\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/valerio.nu\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/valerio.nu\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/valerio.nu\/index.php\/wp-json\/wp\/v2\/comments?post=103"}],"version-history":[{"count":8,"href":"https:\/\/valerio.nu\/index.php\/wp-json\/wp\/v2\/posts\/103\/revisions"}],"predecessor-version":[{"id":153,"href":"https:\/\/valerio.nu\/index.php\/wp-json\/wp\/v2\/posts\/103\/revisions\/153"}],"wp:attachment":[{"href":"https:\/\/valerio.nu\/index.php\/wp-json\/wp\/v2\/media?parent=103"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/valerio.nu\/index.php\/wp-json\/wp\/v2\/categories?post=103"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/valerio.nu\/index.php\/wp-json\/wp\/v2\/tags?post=103"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}