I have the below Main App:-
Both packages are in different module and i have "com.app.api is included in the pom.xml of com.app.batch
//commented @SpringBootApplication(scanBasePackages={"com.app.batch", "com.app.api"})
public class App
{
public static void main( String[] args )
{
SpringApplication.run(App.class, args);
}
}
In com.app.api i have class ApiClass
@Service
public class ApiClass {}
in `com.app.batch i have
@Component
public class JobRunner implements CommandLineRunner {
@Override
public void run(String... args) throws Exception {
// TODO Auto-generated method stub
apiClass.getData(1111);
}
}
When i comment @SpringBootApplication(scanBasePackages={"com.app.batch", "com.app.api"}) i get the following error
Field apiClass in com.app.batch.config.JobRunner required a bean of type 'com.com.api.ApiClass' that could not be found.
How can i resolve the issue without using scanBasePackages .I don't want to use scanBasePackages as the module can get added in future and it can get cumberson