и посмотреть медиа
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.
🤔 Чем отличается обычный объект от Bean? В Spring термин Bean (бин) означает объект, управляемый Spring-контейнером. 🟠Обычный объект (Java POJO) Создаётся вручную, Spring о нём ничего не знает class Car { void drive() { System.out.println("Машина едет..."); } } public class Main { public static void main(String[] args) { Car car = new Car(); // Создаём объект вручную car.drive(); } } 🟠Spring Bean (управляемый объект) Spring создаёт и управляет бином через аннотации. import org.springframework.stereotype.Component; @Component // Сообщает Spring, что этот класс - Bean class Car { void drive() { System.out.println("Spring-машина едет..."); } } Теперь объект создаётся Spring-контейнером import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext; public class Main { public static void main(String[] args) { ApplicationContext context = new AnnotationConfigApplicationContext(AppConfig.class); Car car = context.getBean(Car.class); // Получаем Bean из Spring-контейнера car.drive(); } } Ставь 👍 и забирай 📚 Базу знаний
Открыть канал и посмотреть медиаOnly registered users can share their opinion.
Be the first to share your impression of this resource!