Skip to main content

Spring Boot Project Set Up Using Maven And STS


                  In this topic, we discuss, how to set up a new spring boot project and how to run this in the server and how to generate war in command prompt. Here we use STS(Spring tool suite) to build the project. We can also build through Eclipse IDE. For build project, through the eclipse, we need to install external plugins from eclipse market place. We discuss all this in detail but for now, firstly using Spring tool suite let's start building our project. So without wasting any time let's begin.

REQUIERMENTS:

1.STS or Eclipse IDE with Spring tools plug-in
2.Jdk -8 or higher
3.Maven 3 or higher

STEP BY STEP PROCESS:

1.Open The Spring tool suite:



2.Select a work directory where you want to build your project:



3.Step up the project name:




-Set the project name.
-Set the packaging as war because we build a web based application.
-Set groupId(Group Id is the unique identification of your project among all project.It's like your project domain name.for ex:-com.demo,example.test etc etc) and artifactId(Artifact Id is your packaging name.if you create the jar or war,artifact Id is our default packaging name).
-Set your project config file package name at last and click with next.

4.Select the built-in dependencies:



-Choose your spring boot version(by default selected latest version,and we prefer latest version but it's your choice.)
-Here we just create a simple web base project so we just set web is default dependency and press next and finish.

5.Finishing the set up.


-It's take some time to build because maven download the dependencies from maven repository. After download the dependencies,by default project file structure format as shown as above image.
-DeveloperVillageAppllication.java is contain the main method of spring boot application and it's the entry point of project.
-ServletInitializer.java is the configuration file of DispatcherServlet of web application.

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 http://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.1.5.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.dv</groupId>
<artifactId>DeveloperVillage</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>DeveloperVillage</name>
<description>Demo Developer Village project in 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-tomcat</artifactId>
<scope>provided</scope>
</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>

DeveloperVillageAppllication.java


package com.dv;

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

@SpringBootApplication
public class DeveloperVillageApplication {

public static void main(String[] args) {
SpringApplication.run(DeveloperVillageApplication.class, args);
printOutput();
}
public static void printOutput() {
System.out.println("Welcome to Developer Village.Keep touch with us.");
}

}

6.Run the project:



7.See the output:



8.Generate war of project in cmd:

              Move to project directory and open command prompt and run this command mvn clean install .


-After run this command in cmd it take some time to package the dependencies with your project and genreate the war in location "Project Parent directory\target.
-for example:
D:\My Work\Blog\Developer Village\Workspace\DeveloperVillage\target 
path contain our war file.

                           For now this is how to build single module spring boot project with maven and in our next topic we discuss how to set up multi module maven project with spring boot stay tune with us be happy,do what you like, and bye.

Comments

Popular posts from this blog

Send FTL In Email Using Spring Boot

                  In this topic, we discuss mail protocol and how to send email using mail library and how can we sent an email with more dynamic and with some more graphical interface and it's really looking good than the traditional email content. Here we use FTL to make email a more graphical experience. We try to show the example of this topic as possible as an easy way. so without wasting any time let's start the topic. WHAT IS FTL AND WHAT'S THE BENEFITS?          FTL(Free marker template) is a Java-based template language which is used to make the more dynamic and graphical experience on screen. FTL discovered by Apache foundation. It focuses on java based dynamic template design. Free marker template file extension is .ftl which is approx. as same as HTML code but the major difference is, we can send the data from Java source classes to show dynamic content. It's the main focus on MVC architecture which helps in separating web pages designer fro

QR Code Generate using zxing in spring boot

WHAT IS QR CODE AND HOW TO GENERATE QR CODE USING JAVA:           QR Code stands for Quick Response Code first design in Japan in 1994. The QR code is the trademark for a type of matrix barcode. The main purpose is to store information and is easily read by the advanced mobile system. The QR code is the two-dimensional bar code which store the piece of information.in the QR code information are encoded in 4 standardized encoding mode (numeric, alphanumeric, byte/binary, and kanji)    to store data efficiently. In Java, we can generate a QR code using zxing API provided by Google .zxing API support 4000 characters to encode. So without wasting any time let begin with an example for a better preference. PROJECT STRUCTURE: MAVEN DEPENDENCIES:        Put the dependencies on pom.xml pom.xml: <!-- https://mvnrepository.com/artifact/com.google.zxing/core --> <dependency>      <groupId>com.google.zxing

Scheduler(Task Executor) In Spring Boot

WHAT IS A SCHEDULER?       Firstly know about what is scheduling. Scheduling is a process that executing a task in a certain time period. A scheduler is a tool, the main objective is to implement the scheduling process. Mainly scheduler is used to perform the batch task for the repeated manner and perform the action of task without any outer other events. IMPLEMENTATION OF SCHEDULER IN SPRING BOOT:        In spring boot we can implement scheduler in multiple ways but here we use the annotation to implement the scheduler. In spring boot we can implement scheduler using @Scheduled annotation. The @Scheduled annotation internally uses the TaskScheduler interface to schedule a task. To enable the @Scheduled annotation we must use @EnableScheduling annotation in the Configuration file.        Let's start with an example of task scheduler. Her we use STS(spring tool suite) to build the spring boot project. First, build a project with web configuration. PROJECT S