Bird
0
0

You accidentally place a Java class in src/main/resources instead of src/main/java. What problem will this cause when building the Spring Boot project?

medium📝 Debug Q6 of 15
Spring Boot - Fundamentals
You accidentally place a Java class in src/main/resources instead of src/main/java. What problem will this cause when building the Spring Boot project?
AThe class will not compile because resources are not compiled as Java source
BThe class will compile but not run
CThe class will be treated as a configuration file
DNo problem; it will work normally
Step-by-Step Solution
Solution:
  1. Step 1: Understand compilation of Java source files

    Java classes must be in src/main/java to be compiled by the build tool.
  2. Step 2: Recognize resources folder role

    Files in src/main/resources are copied as-is and not compiled.
  3. Final Answer:

    The class will not compile because resources are not compiled as Java source -> Option A
  4. Quick Check:

    Java source must be in src/main/java to compile [OK]
Quick Trick: Java classes must be in src/main/java to compile [OK]
Common Mistakes:
  • Thinking resources folder compiles Java code
  • Assuming misplaced class runs anyway
  • Confusing resources with source code

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes