Consider a Spring Boot application with the default embedded Tomcat server. What is the behavior when you run the app?
Think about what embedded means in this context.
Spring Boot includes an embedded Tomcat server by default, so the app runs standalone and listens on port 8080 without needing an external server.
In application.properties, which property correctly sets the embedded server port to 9090?
Look for the standard prefix for server settings in Spring Boot.
The correct property to set the embedded server port is server.port. Other options are invalid keys.
Given this Spring Boot main class, why does the app fail to start the embedded server?
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class MyApp {
public static void main(String[] args) {
SpringApplication.run(MyApp.class, args);
}
}import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class MyApp { public static void main(String[] args) { SpringApplication.run(MyApp.class, args); } }
Consider the dependencies required to auto-configure an embedded server.
The main class is correct and SpringApplication.run(MyApp.class, args) works fine, but without a dependency like spring-boot-starter-web, no embedded server (Tomcat) is included or auto-configured, so none starts.
Why do developers prefer embedded servers in Spring Boot applications?
Think about deployment simplicity and portability.
Embedded servers let you package the app with the server inside, so you can run it anywhere without extra setup.
Given this application.properties and main class, what port will the embedded server listen on?
application.properties:
server.port=7070
Main class:
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class App {
public static void main(String[] args) {
SpringApplication.run(App.class, args);
}
}application.properties: server.port=7070 import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class App { public static void main(String[] args) { SpringApplication.run(App.class, args); } }
Check how Spring Boot reads properties for server configuration.
The server.port property overrides the default 8080 port, so the embedded server listens on 7070.