使用junit4的Spring自动布线

使用junit4的Spring自动布线,spring,selenium,junit4,autowired,Spring,Selenium,Junit4,Autowired,我无法在基于selenium的框架中实现自动布线。以下是我的POM依赖项: <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>5.2.9.RELEASE</version> <scope>runtime</scop

我无法在基于selenium的框架中实现自动布线。以下是我的POM依赖项:

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-context</artifactId>
    <version>5.2.9.RELEASE</version>
    <scope>runtime</scope>
</dependency>
我设置了一个junit规则链,外部规则在其中实例化应用程序上下文:

  @Override
  public void evaluate() throws Throwable {

    ApplicationContext appContext = new AnnotationConfigApplicationContext(AppConfig.class);
    WebDriver driver = (WebDriver) appContext.getBean("driver");

      base.evaluate();

  } 
调用appContext.getBean(“驱动程序”)确实成功地从appContext获取驱动程序,但测试类和内部规则上的自动连接不起作用。驱动程序总是空的。所有文件当前都存在于测试包中,所有规则和测试类都被注释为@Component,并且具有@Autowired webdriver属性作为类的一部分。我在设置Spring时哪里出错了

  @Autowired
  public WebDriver driver;
  @Autowired
  public WebDriver driver;