Square CSS

Showing posts with label hello world in spring boot. Show all posts
Showing posts with label hello world in spring boot. Show all posts

Thursday, October 18, 2018

Spring Boot : Hello World Example

Create a Spring Boot application to print "Hello World".

Prerequisites for Creation of Spring Boot :

  • Java with version 1.6 or above. Better to use the latest version.
  • If using Maven then 3.2 or above.
  • If using Gradle then 2.9 or above.
  • Plugin of Spring Tool Suit enabled in IDE like eclipse.
  • Basic knowledge of  Spring Framework.

Versions Used :

  • Java 1.8
  • Spring Boot 1.5.9
  • Eclipse 4.6.9 Neon

Create a Maven project and provide the dependency :

  • Go to File >> New >> Maven Project.
  • Provide Artifact Id as your project name. In this case, it is SpringBootTutorial.

    


  •  Provide the following dependencies in the pom.xml file.


  <parent>
       <groupId>org.springframework.boot</groupId>
       <artifactId>spring-boot-starter-parent</artifactId>    
       <version>1.5.9.RELEASE</version>
  </parent>
  <dependencies>
      <dependency>
           <groupId>org.springframework.boot</groupId>
           <artifactId>spring-boot-starter-web</artifactId>                 
      </dependency>
  </dependencies>

  • Provide the mapping for the method to return "Hello World".

  @Controller
  @EnableAutoConfiguration
  public class SpringBootTutorial{

@RequestMapping("/")
@ResponseBody
String Home() {
return "Hello World";
}
public static void main(String[] args) {
SpringApplication.run(SpringBootTutorial.class, args);    
}

 }

  • Run as Spring Boot App.
     
  • Go to the browser and provide the URL localhost:[portNumber]/pathForMethod.

Refer the video tutorial :




Some Algorithms

Algorithm: Tower of Hanoi

Tower of Hanoi consists of three towers called as pegs with n number of rings. Rings are of different size.  Conditions to be fulfill...

Popular Posts