0
0
Spring Bootframework~10 mins

Embedded server concept in Spring Boot - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to define a Spring Boot application with an embedded server.

Spring Boot
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class Application {
    public static void main(String[] args) {
        SpringApplication.[1](Application.class, args);
    }
}
Drag options to blanks, or click blank then click option'
Aexecute
Bstart
Claunch
Drun
Attempts:
3 left
💡 Hint
Common Mistakes
Using methods like start() or launch() which do not exist in SpringApplication.
Forgetting to pass the application class as the first argument.
2fill in blank
medium

Complete the code to specify the embedded server port in application.properties.

Spring Boot
server.[1]=8081
Drag options to blanks, or click blank then click option'
Aport
Bhost
Caddress
Durl
Attempts:
3 left
💡 Hint
Common Mistakes
Using server.host or server.address which are not valid for port configuration.
Setting the port in code instead of properties file.
3fill in blank
hard

Fix the error in the code to create a REST controller with embedded server.

Spring Boot
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloController {
    @GetMapping("/hello")
    public String [1]() {
        return "Hello, World!";
    }
}
Drag options to blanks, or click blank then click option'
Ahello
BgetHello
CsayHello
DhelloWorld
Attempts:
3 left
💡 Hint
Common Mistakes
Using invalid method names or names that conflict with annotations.
Omitting the method name entirely.
4fill in blank
hard

Fill both blanks to configure the embedded Tomcat server's max threads and port in application.properties.

Spring Boot
server.[1]=9090
server.tomcat.threads.[2]=200
Drag options to blanks, or click blank then click option'
Aport
Bmax
Cmin-spare
Daddress
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing port with address or host.
Using min-spare instead of max for max thread configuration.
5fill in blank
hard

Fill all three blanks to create a Spring Boot application class with embedded server and a REST endpoint.

Spring Boot
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@SpringBootApplication
@RestController
public class [1] {
    public static void main(String[] args) {
        SpringApplication.[2]([3].class, args);
    }

    @GetMapping("/greet")
    public String greet() {
        return "Greetings from embedded server!";
    }
}
Drag options to blanks, or click blank then click option'
AMyApplication
Brun
CApplication
Dstart
Attempts:
3 left
💡 Hint
Common Mistakes
Mismatching class names in main method and class declaration.
Using incorrect method names instead of run().