Bird
0
0

You want to add a custom property app.title in application.properties and access it in your Spring Boot code. Which of these steps is correct?

hard📝 state output Q15 of 15
Spring Boot - Fundamentals
You want to add a custom property app.title in application.properties and access it in your Spring Boot code. Which of these steps is correct?
AAdd <code>app.title=MyApp</code> in properties and access it with <code>System.getenv("app.title")</code>
BAdd <code>app.title: MyApp</code> in properties and read it with <code>System.getProperty("app.title")</code>
CAdd <code>app.title=MyApp</code> in properties and use <code>@Value("${app.title}")</code> in code
DAdd <code>app.title=MyApp</code> in properties and use <code>@Autowired String app.title</code> in code
Step-by-Step Solution
Solution:
  1. Step 1: Add custom property correctly

    Use key=value syntax: app.title=MyApp in application.properties.
  2. Step 2: Access property in Spring Boot code

    Use @Value("${app.title}") annotation to inject the property value.
  3. Final Answer:

    Add app.title=MyApp in properties and use @Value("${app.title}") in code -> Option C
  4. Quick Check:

    Custom property + @Value injection = correct [OK]
Quick Trick: Use @Value("${key}") to inject properties in code [OK]
Common Mistakes:
  • Using colon instead of equals in properties
  • Trying to get property from environment variables
  • Incorrect use of @Autowired for simple values

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes