Is there any reasonable reason why for the particular class name DeviceServiceImpl
a springboot @Service
does not go through @PostConstruct
method?
This is my super simplified class where it already happens:
@Service
public class DeviceServiceImpl { // Not working due to the "DeviceServiceImpl" name
@PostConstruct
public void init() {
System.out.println("-----------> PostConstructed " + this.getClass().getSimpleName());
}
}
For this particular name: DeviceServiceImpl
code does not go through my @PostConstruct
method.
However, by changing the name for any freaking other name: No matter if DeviceServiceImpl2
, DeviceServiceImp
, ServiceImp
, Aa
.... whatever, it works!!!!
I am getting totally mad:
ie:
@Service
public class DevicServiceImpl { // Working by only changing the name (Supressed "e" from Device"
@PostConstruct
public void init() {
System.out.println("-----------> PostConstructed " + this.getClass().getSimpleName());
}
}
Here is the output for this one, for example:
-----------> PostConstructed DevicServiceImpl
Extra notes:
- I only changed the class name (and obviously in java, the .java file name).
- I did not even change package
- Springboot has been configured to scan in that package (otherwise, wouldn't work for new name)