Java spring boot 1.5.2未加载引发未满足依赖项异常的某些类

Java spring boot 1.5.2未加载引发未满足依赖项异常的某些类,java,spring-boot,Java,Spring Boot,我使用的是springBootVersion='1.5.2.RELEASE',奇怪的是,在执行测试JavaMainApplicationTests时,它为类PlainFileReader提供了以下异常,而这只发生在某些类中。我将PlainFileReader重构到其他类正在工作的包中,并在JavaMainApplicationTests注释中添加了@componentScan,但奇怪的是,只有一些类不工作,原因可能是什么,以及如何解决问题 @Component public class Grap

我使用的是springBootVersion='1.5.2.RELEASE',奇怪的是,在执行测试JavaMainApplicationTests时,它为类PlainFileReader提供了以下异常,而这只发生在某些类中。我将PlainFileReader重构到其他类正在工作的包中,并在JavaMainApplicationTests注释中添加了@componentScan,但奇怪的是,只有一些类不工作,原因可能是什么,以及如何解决问题

@Component
public class Graph<T> {

    @Autowired
    private PlainFileReader pjr;

    private Vertex<T> root;

    private ArrayList<Vertex<T>> vertices = new ArrayList<>();

@RunWith(SpringRunner.class)
@SpringBootTest
@TestPropertySource(properties = "debug=true")
@ComponentScan("com.*")
public class JavaMainApplicationTests 
@Component
public class PlainFileReader {

    @Autowired
    private Parsers parsers;

@RunWith(SpringRunner.class)
@SpringBootTest
@TestPropertySource(properties = "debug=true")
@ComponentScan("com.*")
public class JavaMainApplicationTests 
@Component
public class PlainFileReader {

    @Autowired
    private Parsers parsers;

创建名为“plainFileReader”的bean时出错:通过字段“parsers”表示的未满足的依赖关系;嵌套异常为org.springframework.beans.factory.NoSuchBeanDefinitionException:没有“com.PlainFileReader”类型的符合条件的bean可用:至少需要1个符合autowire候选条件的bean。依赖项注释:{@org.springframework.beans.factory.annotation.Autowired(required=true)}

在创建使用com.test1包创建的spring boot项目时,我的问题得到了解决,但不确定确切原因,如果我在com.test1中创建任何类,但如果我是在com中创建的,则问题得到了解决。这些类不起作用。

解析器类是用@Component注释的,还是您正在为此创建bean?是的,我正在创建bean。