SpringBoot: Can't Autowire Class from Other Jar Library

I have now found the solution on my problem. I have to move up my main MyApp.java one package level higher in order to scan my data libraries.

Instead of putting my MyApp.java under my.app package, I have to move it under my in order to successfully scan my libraries with my.data.jpa and my.data.jdbc packages.


Adding @ComponentScan won't work if the class you're attempting to Autowire isn't annotated with @Component. In order to get this to work, you'll have to annotate a method in your @Configuration class. Something like this should allow you to autowire the class:

@Configuration
public class ConfigClass{

    @Bean
    public JPADataService jpaDataService(){
        return new JPADataService();
    }
}