📘 Premium Read: Access my best content on Medium member-only articles — deep dives into Java, Spring Boot, Microservices, backend architecture, interview preparation, career advice, and industry-standard best practices.
🎓 Top 15 Udemy Courses (80-90% Discount): My Udemy Courses - Ramesh Fadatare — All my Udemy courses are real-time and project oriented courses.
▶️ Subscribe to My YouTube Channel (176K+ subscribers): Java Guides on YouTube
▶️ For AI, ChatGPT, Web, Tech, and Generative AI, subscribe to another channel: Ramesh Fadatare on YouTube
Five ways we can run Spring Boot Application
- Running from an IDE
- Running as a Packaged Application
- Using the Maven Plugin
- Using External Tomcat
- Using the Gradle Plugin
Video
This tutorial is explained in the below Youtube Video. Subscribe to my youtube channel to learn more about Spring boot at Java Guides - YouTube Channel.1. Running from an IDE
2. Running as a Packaged Application
$ java -jar target/myapplication-0.0.1-SNAPSHOT.jar
$ java -Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=8000,suspend=n \
-jar target/myapplication-0.0.1-SNAPSHOT.jar
3. Using the Maven Plugin
$ mvn spring-boot:run
$ export MAVEN_OPTS=-Xmx1024m
4. Using External Tomcat
Step 1: Change the packaging type.
<packaging>war</packaging>
Step 2. Add spring-boot-starter-tomcat as the provided scope
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
Step 3: Spring Boot Application or Main class extends SpringBootServletInitializer
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
@SpringBootApplication
public class Application extends SpringBootServletInitializer{
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(Application.class);
}
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
Spring Boot Deploy WAR file to External Tomcat
5. Using the Gradle Plugin
$ gradle bootRun
$ export JAVA_OPTS=-Xmx1024m
Read 25+ Spring Boot Articles with Source Code on GitHub - Spring Boot Tutorial
Comments
Post a Comment
Leave Comment