#82 Spring Bean Initialization and Transaction Problems

Companies:
Sberbank
Themes:
SpringSpring BootTransactionsCode Review

Explain what is wrong here and provide possible fixes:

@Service
class MyService {

    @Autowired
    private AnotherService anotherService;

    private MyService() {
        initServices(anotherService);
    }

    @Transactional
    private void initServices(AnotherService anotherService) {
        anotherService.doSomething();
    }
}

Question review

Mentor
Answer as you would in a real interview. I’ll ask follow-up questions, then compare your answer with the reference answer and show your accuracy as a %.
Sign in to start the dialogue The mentor keeps the context of the current question and your previous messages.
Sign in