Spring boot field injection with autowire not working in JUnit test
问题 I want to inject DeMorgenArticleScraper in a test. @RunWith(SpringJUnit4ClassRunner.class) public class DeMorgenArticleScraperTest { @Autowired private DeMorgenArticleScraper deMorgenArticleScraper; ... } The DeMorgenArticleScraper component has some configuration going on for itself, but the IDE/compiler is not complaining about them. @Component public class DeMorgenArticleScraper extends NewsPaperArticleScraper { @Autowired public DeMorgenArticleScraper( @Qualifier(