и посмотреть медиа
Java | Interview questions
и посмотреть медиа
Questions and answers for Java developer interviews.
Questions and answers for Java developer interviews.
AI bot for text-to-speech and voice cloning in Telegram. Create audio using neural network quickly and easily.
Selection of typical questions in Java interviews: from JVM basics to Spring and Hibernate. Each question with detailed explanation, code examples, and tips. Suitable for all levels.
🤔 В чем разница между Spring аннотациями Component, Repository и Service? Все три аннотации используются в Spring для создания бинов, но у каждой есть своё предназначение. 🚩`@Component` – базовая аннотация для бина @Component помечает класс как Spring-бин (компонент). Является универсальной аннотацией. Можно применять к любым классам, которые должны управляться Spring-контейнером. @Component public class MyComponent { public void doWork() { System.out.println("Работа компонента"); } } 🚩`@Service` – для бизнес-логики @Service – это специализированный @Component, используемый для сервисных классов (логика приложения). Упрощает понимание кода (показывает, что этот класс содержит бизнес-логику). @Service public class UserService { public String getUser() { return "Пользователь Иван"; } } 🚩`@Repository` – для работы с базой данных @Repository – это специализированный @Component для слоя доступа к данным (DAO, Repository). Автоматически перехватывает SQL-исключения (PersistenceExceptionTranslationPostProcessor) и преобразует их в DataAccessException. @Repository public class UserRepository { public String findUserById(int id) { return "Пользователь с ID " + id; } } Ставь 👍 и забирай 📚 Базу знаний
Открыть канал и посмотреть медиаOnly registered users can share their opinion.
Be the first to share your impression of this resource!