Requisite:
Open eclipse and select File from the menu and click on New.
Select Gradle project from the wizard.
Click Next.
Once the project is created, edit the build.gradle file to include the spring boot dependency.
implementation 'org.springframework.boot:spring-boot-starter-web:2.1.4.RELEASE'
After adding the dependency, your build.gradle file may look like this.
apply plugin: 'java-library'
repositories {
jcenter()
}
dependencies {
api 'org.apache.commons:commons-math3:3.6.1'
implementation 'com.google.guava:guava:23.0'
testImplementation 'junit:junit:4.12'
implementation 'org.springframework.boot:spring-boot-starter-web:2.1.4.RELEASE'
}
Save the "build.gradle" file and refresh/build the Gradle project to have the dependencies downloaded. Once done, you may see the spring boot jars downloaded and available in the project dependencies.
Create a new Java class SpringBootSimpleExample as shown below.
package net.javapedia.springboot;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@EnableAutoConfiguration
public class SpringBootSimpleExample {
@GetMapping("/")
String index() {
return "Hello world! Welcome to my page.";
}
public static void main(String[] args) {
SpringApplication.run(SpringBootSimpleExample.class);
}
}
To run the application, right-click and run as Java application. You may notice the job running and starting the Tomcat embedded container in the log console.
Once you see Started step in the logs, navigate to the browser and go to localhost:8080 URL. You should see the output shown below.
Thanks for visiting this topic! Kindly share your valuable feedback and suggestions below. Thanks for your support.
How does Spring Boot 4 handle dependency injection and what are the core stereotypes?
What is the Spring Boot starter parent (POM) and how do you set up a Spring Boot 4 project?
What are JSpecify nullability annotations in Spring Boot 4 and why are they important?
What are the key breaking changes removed in Spring Boot 4 that were deprecated in Boot 3?
How does Spring Boot 4 testing work with @SpringBootTest and test slices?
What is Spring Security in Spring Boot 4 and what are the key Boot 4 changes?
What is the Java version baseline in Spring Boot 4 and what Java features does it unlock?
What is native API versioning in Spring Boot 4 and how do you use it?
What are @Retryable and @ConcurrencyLimit in Spring Boot 4 and how do they work?
What are HTTP Service Clients in Spring Boot 4 and how do you define them?
What is Spring Boot's application.properties / application.yml and how does configuration work?
What are Spring Boot profiles and how do you use them for environment-specific configuration?
What is Spring Boot Actuator and what does it provide in Boot 4?
How does Spring Boot 4 handle data access with Spring Data JPA?
What is Spring Boot 4 and when was it released?
What is the complete modularisation of Spring Boot 4 and why does it matter?
What is Jakarta EE 11 and what changes does it bring in Spring Boot 4?
How does Spring Boot 4 auto-configuration work and what is the new @AutoConfiguration annotation?
What changed with Jackson in Spring Boot 4 and what are the migration considerations?
|
Interviews Questions |
About Javapedia.net Javapedia.net is for Java and J2EE developers, technologist and college students who prepare of interview. Also this site includes many practical examples. This site is developed using J2EE technologies by Steve Antony, a senior Developer/lead at one of the logistics based company. |
||
| contact: javatutorials2016[at]gmail[dot]com | |||
| Kindly consider donating for maintaining this website. Thanks. |
|||
|
Copyright © 2026, javapedia.net, all rights reserved. privacy policy.
|
|||