0
0
Spring Bootframework~10 mins

Why Spring Boot over plain Spring in Spring Boot - Test Your Understanding

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

Complete the code to create a Spring Boot application main class.

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'
Arun
Blaunch
Cstart
Dexecute
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'start' or 'launch' instead of 'run' causes errors.
2fill in blank
medium

Complete the code to enable auto-configuration in Spring Boot.

Spring Boot
@[1]
public class MyApp {}
Drag options to blanks, or click blank then click option'
AComponentScan
BEnableAutoConfiguration
CConfiguration
DSpringBootApplication
Attempts:
3 left
💡 Hint
Common Mistakes
Using only @EnableAutoConfiguration misses component scanning.
3fill in blank
hard

Fix the error in the Spring Boot application properties file to set server port to 8081.

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' does not set the port.
4fill in blank
hard

Fill both blanks to create a REST controller with a GET mapping in Spring Boot.

Spring Boot
import org.springframework.web.bind.annotation.[1];
import org.springframework.web.bind.annotation.[2];

@[1]
public class HelloController {
    @[2]("/hello")
    public String sayHello() {
        return "Hello, Spring Boot!";
    }
}
Drag options to blanks, or click blank then click option'
ARestController
BGetMapping
CController
DPostMapping
Attempts:
3 left
💡 Hint
Common Mistakes
Using @Controller instead of @RestController misses automatic response body.
5fill in blank
hard

Fill all three blanks to define a Spring Boot application with a component scan and enable configuration properties.

Spring Boot
import org.springframework.context.annotation.[1];
import org.springframework.context.annotation.Configuration;
import org.springframework.boot.context.properties.[2];

@[3]
@[1](
    scanBasePackages = {"com.example.app"}
)
@[2]
public class AppConfig {}
Drag options to blanks, or click blank then click option'
AComponentScan
BEnableConfigurationProperties
CSpringBootApplication
DConfiguration
Attempts:
3 left
💡 Hint
Common Mistakes
Using @SpringBootApplication here would be simpler but this example shows separate annotations.