How to Create a Spring Boot Project in Spring Initializr and Run it in IntelliJ IDEA? - GeeksforGeeks

28 Jan, 2022
Java language is one of the most popular languages among all programming languages. There are several advantages of using the java programming language, whether for security purposes or building large distribution projects. One of the advantages of using Java is that it tries to connect every concept in the language to the real world with the help of the concepts of classes, inheritance, polymorphism, etc.
There are several other concepts present in java that increase the user-friendly interaction between the java code and the programmer such as generic, Access specifiers, Annotations, etc these features add an extra property to the class as well as the method of the java program. In this article, In this article, we will discuss how to change the port number in the spring boot.
Note: First we need to establish the spring application in our project.
Spring Initializr is a web-based tool using which we can easily generate the structure of the Spring Boot project. It also provides various different features for the projects expressed in a metadata model. This model allows us to configure the list of dependencies that are supported by JVM. Here, we will create the structure of an application using a spring initializr and do the following steps.
Steps:
Go to Spring InitializrFill in the details as per the requirementsClick on Generate which will download the starter projectExtract the zip fileCreate a java class with the name Controller and add the annotationGo to the Postman and add URL address and make put request
Go to Spring Initializr
Fill in the details as per the requirements
Click on Generate which will download the starter project
Extract the zip file
Create a java class with the name Controller and add the annotation
Go to the Postman and add URL address and make put request
These steps are sequentially described below with visual aids as follows:
Step 1: Go to Spring Initializr
Step 2: Fill in the details as per the requirements. For this application:
Project: Maven
Language: Java
Spring Boot: 2.2.8
Packaging: JAR
Java: 8
Dependencies: Spring Web
Step 3: Click on Generate which will download the starter project.
Step 4: Extract the zip file. Now open a suitable IDE and then go to File->New->Project from existing sources->Spring-boot-app and select pom.xml. Click on import changes on prompt and wait for the project to sync.
Note: In the Import Project for Maven window, make sure you choose the same version of JDK which you selected while creating the project.
We need to change the port number using the application.properties file in the project structure of the spring application.
application.properties:
server.port=7000
Step 5: Go to src -> main -> java -> com.gfg.Spring.boot.app and run the main application.
Terminal output:
Tomcat is running on server 7000.
zack_aayush
germanshephered48
Java-Spring-Boot
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Stream In Java
Constructors in Java
Exceptions in Java
Functional Interfaces in Java
Different ways of Reading a text file in Java
Generics in Java
Introduction to Java
Comparator Interface in Java with Examples
Internal Working of HashMap in Java
Strings in Java