Spring boot

Spring boot Swagger Configuration

in this tutorial help you to learn Swagger Configuration. in earlier spring testing purpose we used postman tool. this tool is good but we have to install and and every testing need open and check it.instead of we can Swagger . it is best one just only add the dependencies  in to the pom.xml file only its works.

i attached the video below how to Configure Swagger.

you have to add these dependencies  on pom.xml.

  1. maven springfox-swagger2
  2. maven springfox-swagger-ui

 

after that you to create the package config inside the package create the class as SwaggerConfig.

inside the class paste the code.

package com.springschool.firstapp.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

@Configuration
public class SwaggerConfig {

    @Bean
    public Docket SwaggerApi()
    {
        return new Docket(DocumentationType.SWAGGER_2)
                .select()
                .apis(RequestHandlerSelectors.any())
                .paths(PathSelectors.any())
                .build();
    }


}

After that one more thing have do it.go to the main Spring boot application and paste this annotation @EnableSwagger2

i attached the full code below.

@SpringBootApplication
@EnableSwagger2
public class FirstappApplication {

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

}

i have attached the video link below. which will do this tutorials step by step

 

 

admin

Recent Posts

Conditional Statements in Python

Conditional statements in Python allow us to control the flow of execution based on conditions.…

3 weeks ago

Java Beans

A Java Bean is a reusable software component that follows a specific set of conventions.…

4 weeks ago

Java String Methods

Java provides a rich set of built-in methods for handling String operations efficiently. Since strings…

4 weeks ago

Java Developer Jobs

Java remains one of the most in-demand programming languages worldwide, powering everything from enterprise applications…

4 weeks ago

Converting Integer to String in Java

Java provides multiple ways to convert an integer (int) to a string (String). Whether you're…

4 weeks ago

JSP to JSP Communication: A Complete Guide to Dynamic Java Web Development

Java Server Pages (JSP) is a powerful technology used to develop dynamic web applications by…

4 weeks ago