Square CSS

Showing posts with label hello world example. Show all posts
Showing posts with label hello world example. 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 :




Saturday, October 6, 2018

Learn Java : Java Hello World Example!

In this series of tutorials, we will learn java step by step.

Main Method!


Everything inside Java is written in class. The entry point of a Java program is public static void main(String[] args). The functions which are required to be loaded at the start of the Java application is written in the main method.

Print Hello World!

For printing hello world in Java user should write System.out.println("Hello World"); inside the main method. 

Input :


   public static void main(String[] args){   
       System.out.println("Hello World");
   }


Output :



   Hello World                                                 


☛ Next >> Data Types In Java!
                      It specifies the type and size of a variable. They are grouped  ...

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