Spring Boot - Creating a simple web application

Following are the steps to engender a simple Spring Boot Project.

Step 1

Open the Spring initializr https://start.spring.io/

Step 2

Provide the Group and Artifact name. We have provided Group name com.knowledgefactory and Artifact spring boot-demo.

Here I selected the Maven project - language Java - Spring Boot 2.3.8

And integrated Spring web dependency. The single spring-boot-starter-web dependency transitively pulls in all dependencies cognate to web development.




Step 3

Click on the Generate button. When we click on the Generate button, it starts packing the project in a .zip(spring boot-demo.zip) file and downloads the project.

Step 4:

Extract the Zip file

Step 5:

Import the project

File -> Import -> Maven ->Existing Maven Project -> Next -> Browse -> Select the project -> Finish

When the project imports prosperously, we can optically discern the project directory in the Package Explorer. The following image shows the project directory:



SpringbootDemoApplication.java

package com.knowledgefactory.springbootdemo;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class SpringbootDemoApplication {

public static void main(String[] args) {
SpringApplication.run(SpringbootDemoApplication.class, args);
}

}

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>2.3.8.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<groupId>com.knowledgefactory</groupId>
<artifactId>springboot-demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>springboot-demo</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</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-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>

</project>

Step 6:

Right-click on the springboot-demo project -> Run As -> Spring Boot App

Console Output:

OpenJDK 64-Bit Server VM warning: Options -Xverify:none and -noverify were deprecated in JDK 13 and will likely be removed in a future release.

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.1.1.RELEASE)

2021-02-02 21:46:33.887  INFO 11307 --- [           main] c.k.s.SpringbootDemoApplication          : Starting SpringbootDemoApplication on ladmin-H310M-S2 with PID 11307 (/home/sibinmuhammed/Downloads/springboot-demo/target/classes started by sibinmuhammed in /home/sibinmuhammed/Downloads/springboot-demo)
2021-02-02 21:46:33.897  INFO 11307 --- [           main] c.k.s.SpringbootDemoApplication          : No active profile set, falling back to default profiles: default
2021-02-02 21:46:34.952  INFO 11307 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
2021-02-02 21:46:34.990  INFO 11307 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2021-02-02 21:46:34.990  INFO 11307 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/9.0.13
2021-02-02 21:46:34.994  INFO 11307 --- [           main] o.a.catalina.core.AprLifecycleListener   : The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [/usr/java/packages/lib:/usr/lib64:/lib64:/lib:/usr/lib]
2021-02-02 21:46:35.052  INFO 11307 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2021-02-02 21:46:35.052  INFO 11307 --- [           main] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 1075 ms
2021-02-02 21:46:35.170  INFO 11307 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'
2021-02-02 21:46:35.260  INFO 11307 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''
2021-02-02 21:46:35.262  INFO 11307 --- [           main] c.k.s.SpringbootDemoApplication          : Started SpringbootDemoApplication in 1.948 seconds (JVM running for 2.848)

More...



Popular posts from this blog

Spring boot video streaming example-HTML5

DataTable-Pagination example with Spring boot, jQuery and ajax

10 Best Job Posting Sites 2021-2022

Spring boot web project free download:User Registration System

Spring Boot + JPA/Hibernate One to Many mapping example

5 Hardest Puzzle,100% fail answers

Java security AES,SHA256,SHA512,MD5-Spring Boot Project Free Download

Spring Boot-AngularJS-Bootstrap-JPA-CRUD

ReactJS - Bootstrap - Buttons

Spring Boot file upload/download example