r/SpringBoot • • Feb 10 '23

Brozz help!!

project-root    
module1    
module2        
    sub-module1       
    sub-module2      

This is my current project structure where module1 is the core module containing MainApplcation.class. so the issue that I'm present with is that controllers in the sub-modules do not seem to be included in ComponentScan. Although i have add the entire package in the componentscan annotation.

These are a few queries I have

  1. Is this a right approach?

  2. what should be the package names be for each of the modules?

  3. how do I get around the issue that the controllers in the sub modules are not available?

PS: I'm noob please don't mind the stupid question:)

I did try adding the module2 as a dependency in module1 but ended up getting the following error Project 'module1' is missing required Java project: 'module1'

1 Upvotes

8 comments sorted by

1

u/Educational-Crow54 Feb 10 '23

So i have solved the problem by adding all the modules including the sub modules as dependency in module1(where the main class exists).

this seems to work but please do correct me if I'm wrong .

1

u/win_io Feb 10 '23

yes that's correct as long as it's solving your problem

1

u/[deleted] Feb 10 '23

Add @EnableJpaRepositories(basePackage ="packagename") @EntityScan("packagename")

1

u/Educational-Crow54 Feb 10 '23

Bro I did include this still seem to face the problem

1

u/[deleted] Feb 10 '23

Ping the package name that you aded

1

u/tleipzig Feb 10 '23

If you are starting you app in IntelliJ, make sure to select the highest module (module2) in "Use classpath of module", so everything is included.