EDUCBA

EDUCBA

MENUMENU
  • Free Tutorials
  • Free Courses
  • Certification Courses
  • 600+ Courses All in One Bundle
  • Login
Home Software Development Software Development Tutorials Spring Tutorial spring boot debug
Secondary Sidebar
Spring Tutorial
  • Spring Boot
    • What is Spring Boot
    • Spring Boot flyway
    • Spring Boot framework
    • Spring Boot Logback
    • Spring Boot actuator endpoints
    • Spring Boot gRPC
    • Spring Boot jdbctemplate example
    • Spring Boot ehcache
    • Spring Boot Architecture
    • Spring Boot Port
    • Introduction of spring boot
    • Spring Boot ide
    • Spring Boot Netty
    • Spring Boot ORM
    • Spring Boot Versions
    • Spring Boot JUnit
    • Spring Boot Keycloak
    • Spring Boot gradle
    • Spring Boot Lombok
    • Spring Boot autowired
    • Spring Boot bean
    • Spring Boot hibernate
    • Spring Boot integration test
    • Spring Boot jdbc
    • Spring Boot MongoDB
    • Spring Boot postgresql
    • Spring Boot rest
    • Spring Boot swagger
    • Spring Boot thymeleaf
    • Spring Boot Unit Test
    • Spring Boot Webflux
    • Spring Boot webclient
    • Spring Boot kubernetes
    • Spring Boot Properties
    • Spring Boot Validation
    • Spring Boot Feature
    • Spring Boot Application
    • Spring Boot email
    • Spring Boot MVC
    • Spring Boot Exception Handling
    • Spring Boot Starter Parent
    • Spring Boot Docker
    • Spring Boot Logging
    • Spring Boot Query
    • Spring Boot Multiple Data Sources
    • Spring Boot Basic Authentication
    • Spring Boot Test
    • Spring Boot jwt
    • Spring Boot Liquibase
    • Spring Boot Prometheus
    • Spring Boot debug
    • Spring Boot GraalVM
    • Spring Boot Batch
    • Spring Boot controller
    • Spring Boot CLI
    • Spring Boot file upload
    • Spring Boot interceptor
    • Spring Boot Service
    • Spring Boot Configuration
    • Spring Boot Datasource Configuration
    • Spring Boot Annotations
    • Spring Boot Starter We
    • Spring Boot Actuator
    • Spring Boot DevTools
    • Spring Boot Repository
    • Spring Boot Dependencies
    • Spring Boot Path Variable
    • Spring Boot Microservices
    • Spring Boot Run Command
    • Spring Boot application.properties
    • Spring Boot Transaction Management
    • Spring Boot Banner
    • Spring Boot JPA
    • Spring Boot Change Port
    • Spring Boot RestTemplate
    • Spring Boot cors
    • Spring Boot HTTPS
    • Spring Boot OAuth2
    • Spring Boot Profiles
    • Spring Boot Interview Questions
    • Spring Boot filter
    • Spring boot logging level
    • Spring Boot Cache
    • Spring Boot Advantages
    • Spring Boot Scheduler
    • Spring Boot Initializr
    • Spring Boot Maven
    • Spring Boot Admin
    • Spring Boot Tomcat
    • Spring Boot WebSocket
    • Spring Boot Executable Jar
    • Spring Boot CommandLineRunner
    • Spring Boot DataSource
    • Spring Batch Scheduler
    • Spring Batch Example
    • Spring Batch Tasklet
    • Spring Batch Admin
    • Spring Batch
    • Spring Boot Qualifier
    • Spring Boot War
    • Spring Boot Test Configuration
  • Spring
    • What is Spring Framework?
    • Spring Architecture
    • What is Spring Integration?
    • IoC Containers
    • What is AOP?
    • Spring Modules
    • Spring Batch Processing
    • Spring Batch Partitioner
    • Spring Batch Job
    • Spring AOP
    • Spring Expression Language
    • Dependency Injection in Spring
    • Spring Batch Architecture
    • Spring framework Interview Questions
  • Spring Cloud Basics
    • What is Spring Cloud
    • Spring Cloud Contract
    • Spring Cloud Components
    • Spring Cloud Version
    • Spring Cloud Data Flow
    • Spring cloud stream
    • Spring Cloud Dependencies
    • Spring cloud microservices
    • spring cloud gateway
    • Spring Cloud Config
    • Spring Cloud Kubernetes
    • Spring Cloud Sleuth

Related Courses

Spring Boot Certification Course

Spring Framework Course Training

All in One Data Science Course

spring boot debug

spring boot debug

Introduction to spring boot debug

Spring boot debug is the most important tool which was used to write the software. We can debug our application by using eclipse and spring tool suite. The java virtual machine does not enable debugging by default due to the java virtual machine (JVM). It will be creating additional overhead inside into the java virtual machine. It is also a security concern for application which was publically accessible.

What is spring boot debug?

  • Basically, application debugging is performed at the time of development; it was not performed in a production environment.
  • Before running debugging on the application environment, first, we need to configure the java virtual machine on the application server for running debugging.
  • We can also enable the debugging by command-line tool or do this by using IDE. For example, the command to set the command line argument for a java virtual machine is as follows.

-agentlib:jdwp (java debug wire protocol) = transport = dt_socket, server=y, suspend = n, address = 8000

  • Agentlib jdwp is used to enable the java to debug wire protocol inside into the java virtual machine. This is nothing but the main command line argument which was used to enable the debugging.
  • Transport dt_socket is used in a network socket to debug the connections. Other option of Unix socket and shared memory contains the other application options.
  • The server contains the value as Y, which was used to listen to the debugger connection. While setting the server debugger connection value as N, this process will try for connecting to the debugger instead of the incoming connection.
  • Suspend contains the value as N; this parameter doesn’t wait for debugging connection at the startup. Instead, the application will start normally at the time when we have attached the debugger.
  • While setting address as 8000, while setting network port which was java virtual machine is listening from the debug connection.
  • The values from the standard and it will work in most the cases which were used in operating systems.
  • As we know that spring boot application is starting in different types. We can also start the spring boot application by using –jar options.

How to spring boot debug?

  • Below are the steps which were shown on how to debug the spring boot application are as follows.
  1. Build the application service by using debug mode.
  2. Modify the application docker file to expose the port of debug into the image of docker. After modifying the image of the docker, run our application in the mode of debug.
  3. After modifying the docker image, the next step is to deploy the docker container while using the debug container exposed.
  4. After deploying the docker container, the next step is to debug the session using the spring tool suite or eclipse.
  • At the time of debugging the spring boot application, we need to compile the service using additional information after enabling the debugging while runtime.
  • We can be done it by adding the same by using the javac parameter, -g is the build script of our spring boot application.
  • We can also enable debug logging by enabling the same. Enable debug logging it doesn’t mean displaying all the logs at debug level.
  • After enabling debug log, it will display useful information related to the initialization of the container, so we need to check which beans we need to create using configuration.

Spring Boot Applications debug

Below examples shows to create war file of spring boot project are as follows.

  • Create project template using spring initializer and give a name to project –

In the below step, we have provided project group name as com.example, artifact name as springbootWar, project name as springbootWar, and selecting java version as 11.

Start Your Free Software Development Course

Web development, programming languages, Software testing & others

All in One Software Development Bundle(600+ Courses, 50+ projects)
Python TutorialC SharpJavaJavaScript
C Plus PlusSoftware TestingSQLKali Linux
Price
View Courses
600+ Online Courses | 50+ projects | 3000+ Hours | Verifiable Certificates | Lifetime Access
4.6 (86,754 ratings)

Group – com.example
Artifact name – springbootWar
Name – springbootWar
Description - Project for springbootWar
Spring boot – 2.5.5
Project – Maven project
Java – 11
Package name - com.example.springbootWar
Dependencies – spring web.

spring boot debug output 1

  • After generating project extract files and open this project by using spring tool suite –

spring boot debug output 2

  • After opening the project using the spring tool suite, check the project and its files –

output 3

  • Create the main class –

Code –

@SpringBootApplication
public class springbootdebug
{
public static void main(String[] args)
{
SpringApplication.run (springbootdebug.class, args);
System.out.println ("spring boot debug");
}
}

output 4

  • Debug the application –

output 5

Spring Boot Debug Servers

  • Spring boot debug server provides the script for stopping and starting the application.
  • Below is the spring boot debug server are as follows.
  1. Tomcat
  2. Wildfly
  3. Web logic
  4. Glassfish
  5. Jetty
  • We can start the tomcat server by using the execution file name as Catalina.sh. For example, to start debug server by using tomcat server, we are using below command are as follows.

# catalina.sh jpda start

  • Default argument of tomcat server is using the network socket which was listening to the port by using 8000 with suspend parameter as N.
  • We can start the wildfly server by using the execution file name as stand-alone.sh. To start the wildfly server by using debug enables, we need to add debug.
  • We can start the web logic server by using the execution file name as startWeblogic.sh. To start the web logic server by using debug enables, we need to set the environment variable to debug flag as true.
  • We can start the glassfish server by using the execution file name as asadmin. To start the glassfish server by using debug enabled, we need to use debug.
  • The jetty application server does not come with a startup script. However, we can starting the jetty server by using the java command.

Spring boot debug types

  • We can configure the spring boot to debug the application by configuring the application.properties file.
  • We can also debug our spring boot-microservices which were hosted on the docker container.
  • We can start our local application by enabling the debug mode on of our spring boot application.
  • By using debug mode enables we can debug the spring boot application, which was hosted on a remote server.
  • Below is the type of remote debugging is as follows.
  • Start application locally by using debug mode.
  • Start uberjar in debug mode.
  • Start the application on the open shift in debug mode.
  • Attach debugger to application.

Conclusion

Spring boot debug is the most important tool which was used for writing the software. We can debug our application by using eclipse and spring tool suite. Before running debugging on the application environment, first, we need to configure the java virtual machine on the application server to run debugging.

Recommended Articles

This is a guide to spring boot debug. Here we discuss the steps which show how to debug the spring boot application along with the examples. You may also have a look at the following articles to learn more –

  1. Spring Boot Logging
  2. Spring Boot cors
  3. Spring Boot HTTPS
  4. Spring Boot Banner
Popular Course in this category
Spring Boot Training Program (2 Courses, 3 Project)
  2 Online Courses |  3 Hands-on Projects |  22+ Hours |  Verifiable Certificate of Completion
4.5
Price

View Course

Related Courses

Spring Framework Training (4 Courses, 6 Projects)4.9
All in One Data Science Bundle (360+ Courses, 50+ projects)4.8
0 Shares
Share
Tweet
Share
Primary Sidebar
Footer
About Us
  • Blog
  • Who is EDUCBA?
  • Sign Up
  • Live Classes
  • Corporate Training
  • Certificate from Top Institutions
  • Contact Us
  • Verifiable Certificate
  • Reviews
  • Terms and Conditions
  • Privacy Policy
  •  
Apps
  • iPhone & iPad
  • Android
Resources
  • Free Courses
  • Java Tutorials
  • Python Tutorials
  • All Tutorials
Certification Courses
  • All Courses
  • Software Development Course - All in One Bundle
  • Become a Python Developer
  • Java Course
  • Become a Selenium Automation Tester
  • Become an IoT Developer
  • ASP.NET Course
  • VB.NET Course
  • PHP Course

ISO 10004:2018 & ISO 9001:2015 Certified

© 2022 - EDUCBA. ALL RIGHTS RESERVED. THE CERTIFICATION NAMES ARE THE TRADEMARKS OF THEIR RESPECTIVE OWNERS.

EDUCBA
Free Software Development Course

C# Programming, Conditional Constructs, Loops, Arrays, OOPS Concept

*Please provide your correct email id. Login details for this Free course will be emailed to you

By signing up, you agree to our Terms of Use and Privacy Policy.

EDUCBA Login

Forgot Password?

By signing up, you agree to our Terms of Use and Privacy Policy.

EDUCBA
Free Software Development Course

Web development, programming languages, Software testing & others

*Please provide your correct email id. Login details for this Free course will be emailed to you

By signing up, you agree to our Terms of Use and Privacy Policy.

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you

By signing up, you agree to our Terms of Use and Privacy Policy.

Let’s Get Started

By signing up, you agree to our Terms of Use and Privacy Policy.

This website or its third-party tools use cookies, which are necessary to its functioning and required to achieve the purposes illustrated in the cookie policy. By closing this banner, scrolling this page, clicking a link or continuing to browse otherwise, you agree to our Privacy Policy

Loading . . .
Quiz
Question:

Answer:

Quiz Result
Total QuestionsCorrect AnswersWrong AnswersPercentage

Explore 1000+ varieties of Mock tests View more