Bird
Raised Fist0
Spring Bootframework~20 mins

Multi-module project structure in Spring Boot - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Multi-module Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ component_behavior
intermediate
2:00remaining
How does a multi-module Spring Boot project handle dependencies?

Consider a multi-module Spring Boot project where module A depends on module B. What happens when you build module A?

AModule A can only use module B if both modules are merged into a single jar file.
BModule A ignores module B unless you manually copy module B's jar into module A's classpath.
CModule A must declare module B as a runtime dependency but not as a compile-time dependency.
DModule A automatically includes module B's classes and resources during its build and runtime.
Attempts:
2 left
💡 Hint

Think about how Maven or Gradle handles project dependencies in multi-module setups.

📝 Syntax
intermediate
2:00remaining
Correct parent POM declaration for multi-module Spring Boot project

Which of the following is the correct way to declare a parent POM for a multi-module Spring Boot project?

A
<parent>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-parent</artifactId>
  <version>2.5.0</version>
</parent>
B
<parent>
  <groupId>com.example</groupId>
  <artifactId>parent-project</artifactId>
  <version>1.0.0</version>
</parent>
C
<parent>
  <groupId>com.example</groupId>
  <artifactId>parent-project</artifactId>
  <version>1.0.0</version>
  <scope>compile</scope>
</parent>
D
<parent>
  <groupId>com.example</groupId>
  <artifactId>child-module</artifactId>
  <version>1.0.0</version>
</parent>
Attempts:
2 left
💡 Hint

The parent POM should represent the overall project, not a child module.

🔧 Debug
advanced
3:00remaining
Why does a Spring Boot multi-module project fail to start with NoSuchBeanDefinitionException?

You have a multi-module Spring Boot project. Module A defines a service bean, and module B depends on module A. When running module B, you get NoSuchBeanDefinitionException for the service in module A. What is the most likely cause?

AModule B does not have module A as a dependency in its build configuration.
BThe service bean in module A is not annotated with <code>@Service</code> or <code>@Component</code>.
CModule B's <code>@SpringBootApplication</code> scan does not include module A's packages.
DModule A's service bean is defined as <code>private</code> and cannot be accessed.
Attempts:
2 left
💡 Hint

Think about how Spring Boot scans for beans in multi-module projects.

❓ state_output
advanced
3:00remaining
What is the output when running a multi-module Spring Boot project with conflicting properties?

In a multi-module Spring Boot project, module A and module B both define application.properties files with the same property app.name but with different values. When running the project, which value will Spring Boot use?

AThe value from the module that appears last in the classpath is used.
BThe value from module A's <code>application.properties</code> is used.
CSpring Boot merges both and throws an error due to conflict.
DThe value from module B's <code>application.properties</code> is used.
Attempts:
2 left
💡 Hint

Consider how Spring Boot loads properties from multiple sources.

🧠 Conceptual
expert
4:00remaining
Best practice for sharing common code in multi-module Spring Boot projects

In a large multi-module Spring Boot project, you want to share common utility classes and configurations across multiple modules. What is the best practice to organize this?

ACreate a separate common module that contains shared code and declare it as a dependency in other modules.
BDuplicate the common code in each module to avoid dependency issues.
CPlace all common code in the parent POM file as Java classes.
DUse Spring Boot's auto-configuration to automatically share code without dependencies.
Attempts:
2 left
💡 Hint

Think about modular design and code reuse principles.

Practice

(1/5)
1. What is the main purpose of a multi-module project in Spring Boot?
easy
A. To create multiple databases for one application
B. To run multiple Spring Boot applications simultaneously
C. To split a large project into smaller, manageable parts
D. To avoid using pom.xml files

Solution

  1. Step 1: Understand project organization

    Multi-module projects break a big codebase into smaller modules for easier management.
  2. Step 2: Identify the main goal

    This splitting helps teams work on parts independently and share code efficiently.
  3. Final Answer:

    To split a large project into smaller, manageable parts -> Option C
  4. Quick Check:

    Multi-module = smaller parts [OK]
Hint: Think of dividing work into smaller folders [OK]
Common Mistakes:
  • Confusing multi-module with running multiple apps
  • Thinking it removes the need for pom.xml
  • Assuming it creates multiple databases
2. Which file typically manages all modules in a Spring Boot multi-module project?
easy
A. application.properties
B. module-specific application.yml
C. settings.gradle
D. parent pom.xml

Solution

  1. Step 1: Identify the build management file

    In Maven-based Spring Boot projects, the parent pom.xml controls all modules.
  2. Step 2: Understand file roles

    Other files like application.properties configure app settings, not modules.
  3. Final Answer:

    parent pom.xml -> Option D
  4. Quick Check:

    Parent pom manages modules [OK]
Hint: Parent pom.xml controls modules [OK]
Common Mistakes:
  • Confusing application.properties with module management
  • Thinking settings.gradle is used in Maven projects
  • Assuming module-specific files manage all modules
3. Given a multi-module project with modules core and web, where web depends on core, what happens if core is not built before web?
medium
A. The web module build will fail due to missing dependencies
B. The web module will build successfully without core
C. Both modules will build independently without errors
D. The core module will build automatically after web

Solution

  1. Step 1: Understand module dependencies

    If web depends on core, it needs core built first to access its code.
  2. Step 2: Consequence of build order

    Building web without core causes missing dependency errors and build failure.
  3. Final Answer:

    The web module build will fail due to missing dependencies -> Option A
  4. Quick Check:

    Dependent module needs dependency built first [OK]
Hint: Build dependencies before dependents [OK]
Common Mistakes:
  • Assuming modules build independently
  • Thinking build order does not matter
  • Believing dependent modules build automatically
4. You have a multi-module Spring Boot project but the web module cannot find classes from the core module. What is the most likely cause?
medium
A. The core module is not listed as a dependency in web's pom.xml
B. The web module has no application.properties
C. The parent pom.xml is missing the modules section
D. The core module is using a different Java version

Solution

  1. Step 1: Check module dependencies

    If web cannot find core classes, it likely lacks a dependency declaration on core.
  2. Step 2: Verify dependency declaration

    Adding core as a dependency in web's pom.xml fixes class visibility.
  3. Final Answer:

    The core module is not listed as a dependency in web's pom.xml -> Option A
  4. Quick Check:

    Missing dependency causes class not found [OK]
Hint: Always declare module dependencies in pom.xml [OK]
Common Mistakes:
  • Ignoring dependency declarations
  • Thinking application.properties affects class visibility
  • Assuming Java version mismatch causes missing classes
5. In a multi-module Spring Boot project, you want to share common utility classes across modules without duplicating code. Which approach is best?
hard
A. Copy utility classes into each module's source folder
B. Create a separate common module and add it as a dependency to other modules
C. Put all utility classes in the parent pom.xml
D. Use application.properties to share utility classes

Solution

  1. Step 1: Identify code sharing strategy

    To avoid duplication, create a dedicated common module for shared utilities.
  2. Step 2: Use module dependencies

    Other modules add common as a dependency to access shared code cleanly.
  3. Final Answer:

    Create a separate common module and add it as a dependency to other modules -> Option B
  4. Quick Check:

    Shared code in common module [OK]
Hint: Use a common module for shared code [OK]
Common Mistakes:
  • Copying code causes duplication and maintenance issues
  • Trying to put code in pom.xml (not for code)
  • Using properties files to share classes
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard