Java Cucumber Spring测试@ConfigurationProperties不向对象字段注入属性

Java Cucumber Spring测试@ConfigurationProperties不向对象字段注入属性,java,spring,cucumber,configurationproperty,Java,Spring,Cucumber,Configurationproperty,我开发了springboot+cucumber和基于硒的测试工具。 我的春瓜基础设施是由 我的财产类别是 @Data @Configuration @ConfigurationProperties(prefix = "application") public class ApplicationProperty { private String baseUrl; } 我的application.yml是 application: base-url: https://www.goog

我开发了springboot+cucumber和基于硒的测试工具。 我的春瓜基础设施是由

我的财产类别是

@Data
@Configuration
@ConfigurationProperties(prefix = "application")
public class ApplicationProperty {
    private String baseUrl;
}
我的application.yml是

application:
   base-url: https://www.google.com/
我的步骤定义是

public class SomeStep{
   @Autowired
   private SomePage somePage;

   @Autowired
   private ApplicationProperty applicationProperty;

   @Given("^Go to Some Page$")
   public void catalogUserIsOnTheLoginPage() throws Throwable {
       somePage.navigateTo("some url");
       applicationProperty.getBaseUrl(); //Cucumber spring do not inject configuration property here.
   }
   ...etc
}
当我用@SpringBootTest注释我的步骤定义时

@SpringBootTest
public class SomeStep{
   @Autowired
   private SomePage somePage;

   @Autowired
   private ApplicationProperty applicationProperty;

   @Given("^Go to Some Page$")
   public void catalogUserIsOnTheLoginPage() throws Throwable {
       somePage.navigateTo("some url");
       applicationProperty.getBaseUrl(); //Cucumber spring do inject configuration property here.
   }
   ...etc

}
现在,spring inject应用程序属性,但IntelliJ给了我一个错误: 无法自动连线。找不到类型为“somePage”的bean

依赖项包括:

dependencies {
    compile('org.springframework.boot:spring-boot-starter')
    compile('org.seleniumhq.selenium:selenium-server:3.13.0')
    compile('org.projectlombok:lombok')
    testCompile('org.springframework.boot:spring-boot-starter-test')
    testCompile('io.cucumber:cucumber-java:2.4.0')
    testCompile('io.cucumber:cucumber-junit:2.4.0')
    testCompile('io.cucumber:cucumber-spring:2.4.0')
    testCompile('org.springframework:spring-tx')
}
Spring启动版本为2.0.3。发布版

步骤定义类声明中缺少@ContextConfiguration(…)。例如,我已经看到了这个答案,但它不起作用@SpringBootTest也会初始化spring上下文,但idea会给出我上面解释的错误。在该属性配置类中包括@ConfigurationProperties(prefix=“application.yaml”),或者您可以在@SpringBootTest类的SomeSteps类中使用@TestPropertySource(“classpath:application.yaml”)
dependencies {
    compile('org.springframework.boot:spring-boot-starter')
    compile('org.seleniumhq.selenium:selenium-server:3.13.0')
    compile('org.projectlombok:lombok')
    testCompile('org.springframework.boot:spring-boot-starter-test')
    testCompile('io.cucumber:cucumber-java:2.4.0')
    testCompile('io.cucumber:cucumber-junit:2.4.0')
    testCompile('io.cucumber:cucumber-spring:2.4.0')
    testCompile('org.springframework:spring-tx')