Thursday 5 September 2024

Java Spring Boot First Example in Spring Tool Suite(STS)

 

JAVA with Silan Software

First Spring Boot Application in STS

pom.xml

<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">

         <modelVersion>4.0.0</modelVersion>

         <parent>

                  <groupId>org.springframework.boot</groupId>

                  <artifactId>spring-boot-starter-parent</artifactId>

                  <version>3.3.3</version>

                  <relativePath/> <!-- lookup parent from repository -->

         </parent>

         <groupId>com.iter</groupId>

         <artifactId>SpringBootFirstExample</artifactId>

         <version>0.0.1-SNAPSHOT</version>

         <name>SpringBootFirstExample</name>

         <description>My First Spring Boot Example</description>

         <url/>

         <licenses>

                  <license/>

         </licenses>

         <developers>

                  <developer/>

         </developers>

         <scm>

                  <connection/>

                  <developerConnection/>

                  <tag/>

                  <url/>

         </scm>

         <properties>

                  <java.version>17</java.version>

         </properties>

         <dependencies>

                  <dependency>

                           <groupId>org.springframework.boot</groupId>

                           <artifactId>spring-boot-starter-web</artifactId>

                  </dependency>

 

                  <dependency>

                           <groupId>org.springframework.boot</groupId>

                           <artifactId>spring-boot-devtools</artifactId>

                           <scope>runtime</scope>

                           <optional>true</optional>

                  </dependency>

                  <dependency>

                           <groupId>org.springframework.boot</groupId>

                           <artifactId>spring-boot-starter-test</artifactId>

                           <scope>test</scope>

                  </dependency>

         </dependencies>

 

         <build>

                  <plugins>

                           <plugin>

                                    <groupId>org.springframework.boot</groupId>

                                    <artifactId>spring-boot-maven-plugin</artifactId>

                           </plugin>

                  </plugins>

         </build>

 

</project>

 

TestController.java

package com.soa.controller;

 

import org.springframework.web.bind.annotation.GetMapping;

import org.springframework.web.bind.annotation.RestController;

 

@RestController

public class TestController {

        

         @GetMapping("/hello")

         public String display()

         {

                  return "Welcome to Java Spring Boot";

         }

        

 

}

 

 




No comments:

Post a Comment