I have a parent Spring boot project that I use as a dependency for projects that extend client capabilities. Initially, to make sure everything else worked correctly, I installed the base package for the client project as the same as the parent project, and everything worked as expected. However, adding the Application class to the subpackage, I began to get exceptions due to the lack of beans and components.
For example, the parent project has the base package com.example.parent, and the client project has the base package com.example.parent.customerA. At first, none of the parent beans turned out, so I added @ComponentScan("com.example.parent"). Then I got an exception due to the missing bean repository, so I added @EnableJpaRepositories("com.example.parent"). Then I got an exception due to a missing object, so I added @EntityScan("com.example.parent"), and now it works just like when the client project had the same package as the parent.
Is there a cleaner way to load the entire parent project beans and components? . I would prefer to configure the client project so that everything in the parent project loads as if the client project had the same base package. I'm worried that if I had to add these specific annotations for jpa repositories and entities, I might not have all of my databases with some other Spring object that might be added in the future.
source
share