ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml"); boolean containsBean = context.containsBean("userService");
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); context.register(UserService.class); boolean containsBean = context.containsBean("userService");In this example, an `AnnotationConfigApplicationContext` is used to create a container, and a `UserService` class is manually registered with the container using the `register()` method. Then, the `containsBean()` method is used to check if a bean with the name `"userService"` exists in the container. The `containsBean()` method is part of the `org.springframework.context` package library, which can be found in the `spring-context` JAR file.