0
0
Spring Bootframework~10 mins

Why configuration matters 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 load a property value from application.properties.

Spring Boot
@Value("$[1]")
private String appName;
Drag options to blanks, or click blank then click option'
Aapp.name
Bserver.port
Cspring.datasource.url
Dlogging.level
Attempts:
3 left
💡 Hint
Common Mistakes
Using unrelated property keys like server.port or logging.level.
2fill in blank
medium

Complete the code to define a configuration property with a default value.

Spring Boot
@Value("${custom.timeout:[1]")
private int timeout;
Drag options to blanks, or click blank then click option'
A30
Bnull
Ctrue
Ddefault
Attempts:
3 left
💡 Hint
Common Mistakes
Using non-numeric default values like 'true' or 'default'.
3fill in blank
hard

Fix the error in the configuration property injection.

Spring Boot
@Value("$[1]")
private String databaseUrl;
Drag options to blanks, or click blank then click option'
Aspring.datasource-url
Bspring.datasource.url
Cspring.datasource_url
Dspring.datasource url
Attempts:
3 left
💡 Hint
Common Mistakes
Using dashes or underscores instead of dots in property keys.
4fill in blank
hard

Fill both blanks to create a configuration class with a property prefix.

Spring Boot
@ConfigurationProperties(prefix = "[1]")
public class [2]Config {
    private String url;

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }
}
Drag options to blanks, or click blank then click option'
Aapp
Bdatabase
CApp
DDatabase
Attempts:
3 left
💡 Hint
Common Mistakes
Using uppercase prefix or lowercase class names.
5fill in blank
hard

Fill all three blanks to bind nested configuration properties.

Spring Boot
@ConfigurationProperties(prefix = "[1]")
public class [2]Config {
    private final [3] security = new [3]();

    public [3] getSecurity() {
        return security;
    }

    public static class Security {
        private boolean enabled;

        public boolean isEnabled() {
            return enabled;
        }

        public void setEnabled(boolean enabled) {
            this.enabled = enabled;
        }
    }
}
Drag options to blanks, or click blank then click option'
Aserver
BServer
CSecurity
DApplication
Attempts:
3 left
💡 Hint
Common Mistakes
Mismatching prefix and class names or incorrect nested class names.