{"id":96700,"date":"2020-11-18T11:00:00","date_gmt":"2020-11-18T09:00:00","guid":{"rendered":"https:\/\/examples.javacodegeeks.com\/?p=96700"},"modified":"2022-07-07T15:13:18","modified_gmt":"2022-07-07T12:13:18","slug":"java-spring-boot-tutorial","status":"publish","type":"post","link":"https:\/\/examples.javacodegeeks.com\/java-spring-boot-tutorial\/","title":{"rendered":"Java Spring Boot Tutorial"},"content":{"rendered":"<p>This is a tutorial about Java Spring Boot which makes it easy to create stand-alone, production-grade Spring-based Applications that you can &#8220;just run&#8221;. It takes an opinionated view of the platform and third-party libraries so you can get started with minimum fuss.<\/p>\n<p>You can also check this tutorial in the following video:<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><a href=\"https:\/\/www.youtube.com\/watch?v=JEBVIHUA9cA\"><img decoding=\"async\" src=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/07\/Java-Spring-Boot-Tutorial-1024x576.jpg\" alt=\"\" class=\"wp-image-113838\" width=\"512\" height=\"288\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/07\/Java-Spring-Boot-Tutorial-1024x576.jpg 1024w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/07\/Java-Spring-Boot-Tutorial-300x169.jpg 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/07\/Java-Spring-Boot-Tutorial-768x432.jpg 768w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/07\/Java-Spring-Boot-Tutorial.jpg 1280w\" sizes=\"(max-width: 512px) 100vw, 512px\" \/><\/a><figcaption>Java Spring Boot Tutorial &#8211; video<\/figcaption><\/figure>\n<\/div>\n<h2 class=\"wp-block-heading\" id=\"h-1-introduction\">1. Introduction<\/h2>\n<p>Spring boot is used to create stand-alone Spring applications. It has an embedded Tomcat\/Jetty server so we don&#8217;t need to deploy the application explicitly. It provides opinionated &#8216;starter&#8217; dependencies to simplify build configuration. It also provides production-ready features such as metrics, health checks, and externalized configuration.<\/p>\n<p>Spring Boot offers a fast way to build applications. It looks at your classpath and at the beans you have configured, makes reasonable assumptions about what you are missing, and adds those items. With Spring Boot, you can focus more on business features and less on infrastructure. Furthermore it does not generate code or make edits to your files. Instead, when you start your application, dynamically wires up beans and settings and applies them to your application context.<\/p>\n<h2 class=\"wp-block-heading\" id=\"h-2-advantages\">2. Advantages<\/h2>\n<p>Some of the main advantages are listed below:<\/p>\n<ul class=\"wp-block-list\">\n<li>It reduces the time spent on development and increases the overall efficiency of the development team.<\/li>\n<li>The integration of Spring Boot with the Spring ecosystem which includes Spring Data, Spring Security, Spring ORM, and Spring JDBC is easy.<\/li>\n<li>Comes with embedded HTTP servers like Jetty and Tomcat to test web applications.<\/li>\n<li>Helps to avoid all the manual work of writing boilerplate code, annotations, and complex XML configurations.<\/li>\n<li>We can quickly set up and run standalone, web applications, and microservices at very less time.<\/li>\n<\/ul>\n<h2 class=\"wp-block-heading\" id=\"h-3-disadvantages\">3. Disadvantages<\/h2>\n<ul class=\"wp-block-list\">\n<li>Lack of control. Lots of things are done behind the scene.<\/li>\n<li>May unnecessarily increase the deployment binary size with unused dependencies.<\/li>\n<li>Turning legacy spring applications into Spring boot requires a lot of effort and a time-consuming process.<\/li>\n<\/ul>\n<h2 class=\"wp-block-heading\" id=\"h-4-microservice\">4. Microservice<\/h2>\n<p>Microservices architecture&nbsp;refers to a technique that gives modern developers a way to design highly scalable, flexible applications by decomposing the application into discrete services that implement specific business functions. These services, often referred to as \u201cloosely coupled,\u201d can then be built, deployed, and scaled independently.<\/p>\n<p>Each service communicates with other services, through standardised application programming interfaces (APIs), enabling the services to be written in different languages or on different technologies. This differs completely from systems built as monolithic structures where services were inextricably interlinked and could only be scaled together.<\/p>\n<h2 class=\"wp-block-heading\" id=\"h-5-java-spring-boot-starter\">5. Java Spring Boot Starter<\/h2>\n<p>Spring Boot provides a number of starters that allow us to add jars in the classpath. Built-in starters make development easier and rapid. A Spring Boot Starter is a Maven or Gradle module with the sole purpose of providing all dependencies necessary to get started with a certain feature. This usually means that it\u2019s a solitary <code>pom.xml<\/code> or <code>build.gradle<\/code> file that contains dependencies to one or more auto-configure modules and any other dependencies that might be needed.<\/p>\n<p>First define the parent in your <code>pom.xml<\/code> as below:<\/p>\n<pre class=\"brush:xml\">&lt;parent&gt;\n    &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;\n    &lt;artifactId&gt;spring-boot-starter-parent&lt;\/artifactId&gt;\n    &lt;version&gt;2.3.5.RELEASE&lt;\/version&gt;\n&lt;\/parent&gt;<\/pre>\n<p>Now we can define the starter dependencies like below:<\/p>\n<pre class=\"brush:xml\">&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;<\/pre>\n<h2 class=\"wp-block-heading\" id=\"h-6-code\">6. Code<\/h2>\n<p>In this section we will see a working example of a spring boot application. We will build a very simple web controller.<\/p>\n<h3 class=\"wp-block-heading\" id=\"h-6-1-controller\">6.1 Controller<\/h3>\n<p><span style=\"text-decoration: underline\"><em>HelloController.java<\/em><\/span><\/p>\n<pre class=\"brush:java\">package org.javacodegeeks.example;\n\nimport org.springframework.web.bind.annotation.RestController;\nimport org.springframework.web.bind.annotation.RequestMapping;\n\n@RestController\npublic class HelloController {\n\n    @RequestMapping(\"\/\")\n    public String hello() {\n        return \"Greetings from Java Code Geeks\";\n    }\n}<\/pre>\n<p>The class is flagged as a <code>@RestController<\/code>, meaning it is ready for use by Spring MVC to handle web requests. <code>@RequestMapping<\/code> maps <code>\/ <\/code>to the <code>hello()<\/code> method. When invoked from a browser or by using curl on the command line, the method returns pure text. That is because <code>@RestController<\/code> combines <code>@Controller and @ResponseBody, two annotations that result<\/code> in web requests returning data rather than a view.<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<h3 class=\"wp-block-heading\" id=\"h-6-2-application\">6.2 Application<\/h3>\n<p>Let&#8217;s build the <code>Application<\/code> class.<\/p>\n<p><span style=\"text-decoration: underline\"><em>Application.java<\/em><\/span><\/p>\n<pre class=\"brush:java\">package org.javacodegeeks.example;\n\nimport org.springframework.boot.SpringApplication;\nimport org.springframework.boot.autoconfigure.SpringBootApplication;\n\n@SpringBootApplication\npublic class Application {\n\n    public static void main(String[] args) {\n        SpringApplication.run(Application.class, args);\n    }\n}<\/pre>\n<p><code>@SpringBootApplication<\/code>&nbsp;is a convenience annotation that adds all of the following:<\/p>\n<ul class=\"wp-block-list\">\n<li><code>@Configuration<\/code>: Tags the class as a source of bean definitions for the application context.<\/li>\n<li><code>@EnableAutoConfiguration<\/code>: Tells Spring Boot to start adding beans based on classpath settings, other beans, and various property settings. For example, if&nbsp;<code>spring-webmvc<\/code>&nbsp;is on the classpath, this annotation flags the application as a web application and activates key behaviors, such as setting up a&nbsp;<code>DispatcherServlet<\/code>.<\/li>\n<li><code>@ComponentScan<\/code>: Tells Spring to look for other components, configurations, and services in the&nbsp;<code>org.javacodegeeks.example<\/code>&nbsp;package, letting it find the controllers.<\/li>\n<\/ul>\n<p>The&nbsp;<code>main()<\/code>&nbsp;method uses Spring Boot\u2019s&nbsp;<code>SpringApplication.run()<\/code>&nbsp;method to launch an application. Did you notice that there was not a single line of XML? There is no&nbsp;<code>web.xml<\/code>&nbsp;file, either. This web application is 100% pure Java and you did not have to deal with configuring any plumbing or infrastructure.<\/p>\n<p>Run the following command on the terminal to run the application:<\/p>\n<div class=\"wp-block-syntaxhighlighter-code \">\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nmvn spring-boot:run\n<\/pre>\n<\/div>\n<p>You should see the output similar to the following:<\/p>\n<pre class=\"brush:bash\">[INFO] Scanning for projects...\n[INFO] \n[INFO] ------------------------------------------------------------------------\n[INFO] Building spring-boot-example 1.0-SNAPSHOT\n[INFO] ------------------------------------------------------------------------\n[INFO] \n[INFO] &gt;&gt;&gt; spring-boot-maven-plugin:2.3.5.RELEASE:run (default-cli) &gt; test-compile @ spring-boot-example &gt;&gt;&gt;\n[INFO] \n[INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) @ spring-boot-example ---\n[INFO] Using 'UTF-8' encoding to copy filtered resources.\n[INFO] Copying 0 resource\n[INFO] Copying 0 resource\n[INFO] \n[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ spring-boot-example ---\n[INFO] Changes detected - recompiling the module!\n[INFO] Compiling 2 source files to \/Users\/ziameraj16\/study\/JCG\/spring-boot-example\/target\/classes\n[INFO] \n[INFO] --- maven-resources-plugin:3.1.0:testResources (default-testResources) @ spring-boot-example ---\n[INFO] Using 'UTF-8' encoding to copy filtered resources.\n[INFO] skip non existing resourceDirectory \/Users\/ziameraj16\/study\/JCG\/spring-boot-example\/src\/test\/resources\n[INFO] \n[INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) @ spring-boot-example ---\n[INFO] Changes detected - recompiling the module!\n[INFO] \n[INFO] &lt;&lt;&lt; spring-boot-maven-plugin:2.3.5.RELEASE:run (default-cli) &lt; test-compile @ spring-boot-example &lt;&lt;&lt;\n[INFO] \n[INFO] \n[INFO] --- spring-boot-maven-plugin:2.3.5.RELEASE:run (default-cli) @ spring-boot-example ---\n[INFO] Attaching agents: []\n\n  .   ____          _            __ _ _\n \/\\\\ \/ ___'_ __ _ _(_)_ __  __ _ \\ \\ \\ \\\n( ( )\\___ | '_ | '_| | '_ \\\/ _` | \\ \\ \\ \\\n \\\\\/  ___)| |_)| | | | | || (_| |  ) ) ) )\n  '  |____| .__|_| |_|_| |_\\__, | \/ \/ \/ \/\n =========|_|==============|___\/=\/_\/_\/_\/\n :: Spring Boot ::        (v2.3.5.RELEASE)\n\n2020-11-01 21:52:12.754  WARN 4462 --- [           main] o.s.boot.StartupInfoLogger               : InetAddress.getLocalHost().getHostName() took 5004 milliseconds to respond. Please verify your network configuration (macOS machines may need to add entries to \/etc\/hosts).\n2020-11-01 21:52:17.767  INFO 4462 --- [           main] org.javacodegeeks.example.Application    : Starting Application on Mohammads-MacBook.local with PID 4462 (\/Users\/ziameraj16\/study\/JCG\/spring-boot-example\/target\/classes started by ziameraj16 in \/Users\/ziameraj16\/study\/JCG\/spring-boot-example)\n2020-11-01 21:52:17.768  INFO 4462 --- [           main] org.javacodegeeks.example.Application    : No active profile set, falling back to default profiles: default\n2020-11-01 21:52:18.934  INFO 4462 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)\n2020-11-01 21:52:18.953  INFO 4462 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]\n2020-11-01 21:52:18.954  INFO 4462 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat\/9.0.39]\n2020-11-01 21:52:19.085  INFO 4462 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[\/]       : Initializing Spring embedded WebApplicationContext\n2020-11-01 21:52:19.085  INFO 4462 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1243 ms\n2020-11-01 21:52:19.322  INFO 4462 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'\n2020-11-01 21:52:19.550  INFO 4462 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''\n2020-11-01 21:52:19.567  INFO 4462 --- [           main] org.javacodegeeks.example.Application    : Started Application in 17.456 seconds (JVM running for 18.102)\n2020-11-01 21:52:32.873  INFO 4462 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[\/]       : Initializing Spring DispatcherServlet 'dispatcherServlet'\n2020-11-01 21:52:32.874  INFO 4462 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'\n2020-11-01 21:52:32.894  INFO 4462 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Completed initialization in 20 ms\n<\/pre>\n<p>Now open the browser and go to URL: <a href=\"http:\/\/localhost:8080\/\" target=\"_blank\" rel=\"noreferrer noopener\">http:\/\/localhost:8080\/<\/a>. You will see the text as below<\/p>\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"860\" height=\"590\" src=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/11\/spring-boot-application.jpeg\" alt=\"Java Spring Boot app\" class=\"wp-image-96929\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/11\/spring-boot-application.jpeg 860w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/11\/spring-boot-application-300x206.jpeg 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/11\/spring-boot-application-768x527.jpeg 768w\" sizes=\"(max-width: 860px) 100vw, 860px\" \/><figcaption>Figure 1. Spring Boot Application<\/figcaption><\/figure>\n<h2 class=\"wp-block-heading\" id=\"h-7-testing\">7. Testing<\/h2>\n<p>Now let&#8217;s add a test to verify our implementation. We will add the <code>spring-boot-starter-test<\/code> dependency in our pom as below:<\/p>\n<pre class=\"brush:xml\">&lt;dependency&gt;\n    &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;\n    &lt;artifactId&gt;spring-boot-starter-test&lt;\/artifactId&gt;\n    &lt;scope&gt;test&lt;\/scope&gt;\n    &lt;exclusions&gt;\n        &lt;exclusion&gt;\n            &lt;groupId&gt;org.junit.vintage&lt;\/groupId&gt;\n            &lt;artifactId&gt;junit-vintage-engine&lt;\/artifactId&gt;\n        &lt;\/exclusion&gt;\n    &lt;\/exclusions&gt;\n&lt;\/dependency&gt;<\/pre>\n<p>Now let us write the spring test for our controller.<\/p>\n<p><span style=\"text-decoration: underline\"><em>HelloConrollerTest.java<\/em><\/span><\/p>\n<pre class=\"brush:java\">package org.javacodegeeks.example;\n\nimport org.junit.jupiter.api.Test;\nimport org.springframework.beans.factory.annotation.Autowired;\nimport org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;\nimport org.springframework.boot.test.context.SpringBootTest;\nimport org.springframework.test.web.servlet.MockMvc;\nimport org.springframework.test.web.servlet.request.MockMvcRequestBuilders;\n\nimport static org.hamcrest.Matchers.equalTo;\nimport static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;\nimport static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;\n\n@SpringBootTest\n@AutoConfigureMockMvc\npublic class HelloControllerTest {\n\n    @Autowired\n    private MockMvc mvc;\n\n    @Test\n    void hello() throws Exception {\n        mvc.perform(MockMvcRequestBuilders.get(\"\/\"))\n                .andExpect(status().isOk())\n                .andExpect(content().string(equalTo(\"Greetings from Java Code Geeks\")));\n    }\n}<\/pre>\n<p>The <code>@SpringBootTest<\/code> annotation tells Spring Boot to look for the main configuration class (one with <code>@SpringBootApplication<\/code>, for instance) and use that to start a Spring application context. You can run this test in your IDE or on the command line (by running <code>.\/mvn test<\/code>), and it should pass.<\/p>\n<p>The <code>@SpringBootTest<\/code> annotation provides the following features over and above the regular Spring TestContext Framework:<\/p>\n<ul class=\"wp-block-list\">\n<li>Uses <code>SpringBootContextLoader<\/code> as the default <code>ContextLoader<\/code> when no specific <code>@ContextConfiguration(loader=\u2026) <\/code>is defined.<\/li>\n<li>Automatically searches for a <code>@SpringBootConfiguration<\/code> when nested <code>@Configuration<\/code> is not used, and no explicit classes are specified.<\/li>\n<li>Allows custom <code>Environment<\/code> properties to be defined using the properties attribute.<\/li>\n<li>Allows application arguments to be defined using the args attribute.<\/li>\n<li>Provides support for different web environment modes, including the ability to start a fully running web server listening on a defined or random port.<\/li>\n<li>Registers a <code>TestRestTemplate<\/code> and\/or <code>WebTestClient<\/code> bean for use in web tests that are using a fully running web server.<\/li>\n<\/ul>\n<h2 class=\"wp-block-heading\" id=\"h-8-spring-boot-annotation\">8. Spring Boot Annotation<\/h2>\n<p><code>@SpringBootApplication<\/code> annotation can be used to enable the below three features:<\/p>\n<ul class=\"wp-block-list\">\n<li><code>@EnableAutoConfiguration<\/code>: enable Spring Boot\u2019s auto-configuration mechanism<\/li>\n<li><code>@ComponentScan<\/code>: enable <code>@Component <\/code>scan on the package where the application is located<\/li>\n<li><code>@Configuration<\/code>: allow to register extra beans in the context or import additional configuration classes<\/li>\n<\/ul>\n<p><code>@SpringBootApplication<\/code> also provides aliases to customize the attributes of <code>@EnableAutoConfiguration<\/code> and <code>@ComponentScan<\/code>.<\/p>\n<h3 class=\"wp-block-heading\" id=\"h-8-1-component-scan-annotation\">8.1 Component Scan Annotation<\/h3>\n<p>When working with Spring, we can annotate our classes in order to make them into Spring beans. But, besides that,&nbsp;we can tell Spring where to search for these annotated classes. With Spring,&nbsp;we use the&nbsp;<code>@ComponentScan<\/code>&nbsp;annotation along with&nbsp;<code>@Configuration<\/code>&nbsp;annotation to specify the packages that we want to be scanned.<\/p>\n<p>@ComponenentScan annotation configures component scanning directives for use with <code>@Configuration<\/code> classes.It provides support parallel with Spring XML&#8217;s <code>&lt;context:component-scan&gt;<\/code> element. Either <code>basePackageClasses()<\/code> or <code>basePackages()<\/code> (or its alias <code>value()<\/code>) may be specified to define specific packages to scan. If specific packages are not defined, scanning will occur from the package of the class that declares this annotation.<\/p>\n<p>Note that the <code>&lt;context:component-scan&gt;<\/code> element has an <code>annotation-config<\/code> attribute; however, this annotation does not. This is because in almost all cases when using <code>@ComponentScan<\/code>, default annotation config processing (e.g. processing <code>@Autowired<\/code> and friends) is assumed. Furthermore, when using <code>AnnotationConfigApplicationContext<\/code>, annotation config processors are always registered, meaning that any attempt to disable them at the <code>@ComponentScan<\/code> level would be ignored.<\/p>\n<h2 class=\"wp-block-heading\" id=\"h-9-summary\">9. Summary<\/h2>\n<p>In this article, we discussed the Spring Boot application. We saw how easy it is to build an application from scratch. We discussed the advantages and disadvantages of Spring Boot and also looked at some of the most commonly used annotations. We also discussed how easy it is to write unit tests for a Spring Boot application.<\/p>\n<h2 class=\"wp-block-heading\" id=\"h-10-download-source-code\">10. Download Source Code<\/h2>\n<p>That was a tutorial about Java Spring Boot.<\/p>\n<div class=\"download\"><strong>Download<\/strong><br \/>You can download the full source code of this example here: <a href=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/11\/spring-boot-example.zip\"><strong>Java Spring Boot Tutorial<\/strong><\/a><\/div><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is a tutorial about Java Spring Boot which makes it easy to create stand-alone, production-grade Spring-based Applications that you can &#8220;just run&#8221;. It takes an opinionated view of the platform and third-party libraries so you can get started with minimum fuss. You can also check this tutorial in the following video: Java Spring Boot &hellip;<\/p>\n","protected":false},"author":34,"featured_media":1248,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[52],"tags":[1054,1386],"class_list":["post-96700","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-spring","tag-spring","tag-spring-boot"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Java Spring Boot Tutorial - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"This is a tutorial about Java Spring Boot which makes it easy to create stand-alone, production-grade Spring-based Applications that you can &quot;just run&quot;.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/examples.javacodegeeks.com\/java-spring-boot-tutorial\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Java Spring Boot Tutorial - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"This is a tutorial about Java Spring Boot which makes it easy to create stand-alone, production-grade Spring-based Applications that you can &quot;just run&quot;.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/examples.javacodegeeks.com\/java-spring-boot-tutorial\/\" \/>\n<meta property=\"og:site_name\" content=\"Examples Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2020-11-18T09:00:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-07-07T12:13:18+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/spring-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Mohammad Meraj Zia\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Mohammad Meraj Zia\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"9 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-spring-boot-tutorial\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-spring-boot-tutorial\/\"},\"author\":{\"name\":\"Mohammad Meraj Zia\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/442b4f9b8a4aa7e12376464fc354f8ed\"},\"headline\":\"Java Spring Boot Tutorial\",\"datePublished\":\"2020-11-18T09:00:00+00:00\",\"dateModified\":\"2022-07-07T12:13:18+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-spring-boot-tutorial\/\"},\"wordCount\":1258,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-spring-boot-tutorial\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/spring-logo.jpg\",\"keywords\":[\"spring\",\"spring boot\"],\"articleSection\":[\"spring\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/java-spring-boot-tutorial\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-spring-boot-tutorial\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/java-spring-boot-tutorial\/\",\"name\":\"Java Spring Boot Tutorial - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-spring-boot-tutorial\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-spring-boot-tutorial\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/spring-logo.jpg\",\"datePublished\":\"2020-11-18T09:00:00+00:00\",\"dateModified\":\"2022-07-07T12:13:18+00:00\",\"description\":\"This is a tutorial about Java Spring Boot which makes it easy to create stand-alone, production-grade Spring-based Applications that you can \\\"just run\\\".\",\"breadcrumb\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-spring-boot-tutorial\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/java-spring-boot-tutorial\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-spring-boot-tutorial\/#primaryimage\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/spring-logo.jpg\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/spring-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-spring-boot-tutorial\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/examples.javacodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java Development\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Enterprise Java\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/enterprise-java\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"spring\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/enterprise-java\/spring\/\"},{\"@type\":\"ListItem\",\"position\":5,\"name\":\"Java Spring Boot Tutorial\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\",\"url\":\"https:\/\/examples.javacodegeeks.com\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Examples and Code Snippets\",\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/examples.javacodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/examples.javacodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/javacodegeeks\",\"https:\/\/x.com\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/442b4f9b8a4aa7e12376464fc354f8ed\",\"name\":\"Mohammad Meraj Zia\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/06\/IMG-20200324-WA0003-96x96.jpg\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/06\/IMG-20200324-WA0003-96x96.jpg\",\"caption\":\"Mohammad Meraj Zia\"},\"description\":\"Senior Java Developer\",\"sameAs\":[\"http:\/\/www.javacodegeeks.com\/\"],\"url\":\"https:\/\/examples.javacodegeeks.com\/author\/mohammad-zia\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Java Spring Boot Tutorial - Java Code Geeks","description":"This is a tutorial about Java Spring Boot which makes it easy to create stand-alone, production-grade Spring-based Applications that you can \"just run\".","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:\/\/examples.javacodegeeks.com\/java-spring-boot-tutorial\/","og_locale":"en_US","og_type":"article","og_title":"Java Spring Boot Tutorial - Java Code Geeks","og_description":"This is a tutorial about Java Spring Boot which makes it easy to create stand-alone, production-grade Spring-based Applications that you can \"just run\".","og_url":"https:\/\/examples.javacodegeeks.com\/java-spring-boot-tutorial\/","og_site_name":"Examples Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2020-11-18T09:00:00+00:00","article_modified_time":"2022-07-07T12:13:18+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/spring-logo.jpg","type":"image\/jpeg"}],"author":"Mohammad Meraj Zia","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Mohammad Meraj Zia","Est. reading time":"9 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/examples.javacodegeeks.com\/java-spring-boot-tutorial\/#article","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/java-spring-boot-tutorial\/"},"author":{"name":"Mohammad Meraj Zia","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/442b4f9b8a4aa7e12376464fc354f8ed"},"headline":"Java Spring Boot Tutorial","datePublished":"2020-11-18T09:00:00+00:00","dateModified":"2022-07-07T12:13:18+00:00","mainEntityOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/java-spring-boot-tutorial\/"},"wordCount":1258,"commentCount":0,"publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/java-spring-boot-tutorial\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/spring-logo.jpg","keywords":["spring","spring boot"],"articleSection":["spring"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/examples.javacodegeeks.com\/java-spring-boot-tutorial\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/examples.javacodegeeks.com\/java-spring-boot-tutorial\/","url":"https:\/\/examples.javacodegeeks.com\/java-spring-boot-tutorial\/","name":"Java Spring Boot Tutorial - Java Code Geeks","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/java-spring-boot-tutorial\/#primaryimage"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/java-spring-boot-tutorial\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/spring-logo.jpg","datePublished":"2020-11-18T09:00:00+00:00","dateModified":"2022-07-07T12:13:18+00:00","description":"This is a tutorial about Java Spring Boot which makes it easy to create stand-alone, production-grade Spring-based Applications that you can \"just run\".","breadcrumb":{"@id":"https:\/\/examples.javacodegeeks.com\/java-spring-boot-tutorial\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/examples.javacodegeeks.com\/java-spring-boot-tutorial\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/java-spring-boot-tutorial\/#primaryimage","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/spring-logo.jpg","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/spring-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/examples.javacodegeeks.com\/java-spring-boot-tutorial\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/examples.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Java Development","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/"},{"@type":"ListItem","position":3,"name":"Enterprise Java","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/enterprise-java\/"},{"@type":"ListItem","position":4,"name":"spring","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/enterprise-java\/spring\/"},{"@type":"ListItem","position":5,"name":"Java Spring Boot Tutorial"}]},{"@type":"WebSite","@id":"https:\/\/examples.javacodegeeks.com\/#website","url":"https:\/\/examples.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Examples and Code Snippets","publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/examples.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/examples.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/examples.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/442b4f9b8a4aa7e12376464fc354f8ed","name":"Mohammad Meraj Zia","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/06\/IMG-20200324-WA0003-96x96.jpg","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/06\/IMG-20200324-WA0003-96x96.jpg","caption":"Mohammad Meraj Zia"},"description":"Senior Java Developer","sameAs":["http:\/\/www.javacodegeeks.com\/"],"url":"https:\/\/examples.javacodegeeks.com\/author\/mohammad-zia\/"}]}},"_links":{"self":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/96700","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/users\/34"}],"replies":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=96700"}],"version-history":[{"count":0,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/96700\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/media\/1248"}],"wp:attachment":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=96700"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=96700"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=96700"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}