Config:
@Configuration
public class CoreConfig {
@Bean
public StatusService statusService(StatusPersistenceService statusPersistenceService) {
return new StatusEventHandler(statusPersistenceService);
}
}
Class Spring is complaining doesn't have a default constructor
@Configuration
public class StatusEventHandler implements StatusService {
private final StatusPersistenceService statusPersistenceService;
@Autowired
public StatusEventHandler(final StatusPersistenceService statusPersistenceService) {
this.statusPersistenceService = statusPersistenceService;
}
}
Controller where this bean is injected:
@Controller
@RequestMapping("/showStatus")
public class ShowStatusController {
@Autowired
private StatusService statusService;
}
This compiles and the test passes, but when publishing to the app server, I get the below error. Why does Spring think there should be a default no-arg constructor?
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'statusEventHandler'
...
No default constructor found;