Reputation: 65
I am new to Spring and I am kind of lost right now. In this SpringBoot app, I got 3 classes, all 3 inherit from a top abstract class. The three classes are annotated @Component and are in the same package.
AbstractClass
|
|-- @Component ClassA extends abstractClass
|-- @Component ClassB extends abstractClass
|-- @Component ClassC extends abstractClass
Each class starts some threads to do some background work. So basically AbstractClass handles the threads starting logic, while each Class will have its own ExecutorService, and a number of threads, and will implement the behaviour of the runnable object that will be submitted to the ExecutorService.
Here is my Spring Configuration :
@SpringBootApplication
@ComponentScan(basePackages = {"com.myapp.test"})
public class Application {
public static void main(String[] args) throws Exception {
SpringApplication.run(Application.class, args);
}
}
And all my classes are in the package com.myapp.test.listeners.
Funny thing is : ClassA starts and works perfectly. ClassB and ClassC are not started, and do not even appear in the logs.
I already lost 3 hours on that... If one of you has an idea... Thanks!
Upvotes: 0
Views: 1414
Reputation: 65
So I solved my problem, I don't know exactly what was causing the issue... But I know what solves it : one of my class isn't used for now, so I used Excutors.newFixedThreadPool(0)
to create its ExecutorService member... which triggers an exception (that wasn't displayed in the logs).
Strangely, it kept an other Component to be scanned and created... But now it works.
Upvotes: 1