Spring Boot Data MongoDB - Repository is null
<p>I want to develop a little test application using Spring Boot and Spring Data MongoDB. So, in this case, I use default configuration (like localhost:27017/test database) and I try to follow the spring guide (<a href="https://spring.io/guides/gs/accessing-data-mongodb/" rel="nofollow noreferrer">https://spring.io/guides/gs/accessing-data-mongodb/</a>).</p>

<p>I launch my application like this:</p>

<pre><code>@SpringBootApplication
public class Application implements CommandLineRunner {
    private static final Logger LOGGER = LoggerFactory.getLogger(Application.class);

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }

    @Override
    public void run(String... strings) throws Exception {
        (new DummyClass()).load();
    }
}
</code></pre>

<p>The DummyClass is as following:</p>

<pre><code>@org.springframework.stereotype.Component
@ConfigurationProperties(prefix="dummy")
public class DummyClass {

    private static String url;
    private List&lt;Project&gt; projects;


    @Autowired
    private ProjectRepository projectRepository;


    public void setUrl(String url) {
        DummyClass.url = url;
    }


    @Override
    public void load() {

       // (...) creating some project objects

       projectRepository.deleteAll();
       projectRepository.save(this.projects);
    }    
}
</code></pre>

<p>When the projectRepository.deleteAll() statement is executed, I receive un NullPointerException.</p>

<p>For information, below the ProjectRepository interface:</p>

<pre><code>public interface ProjectRepository extends MongoRepository&lt;Project, String&gt;     
{ 
}
</code></pre>

<p>And my package structure is:
    com.test.dummy
        Application.java
    com.test.dummy.components
        DummyClass.java
    com.test.dummy.domain
        Project.java
    com.test.dummy.repositories
        ProjectRepository.java</p>

<p>Can you help me to understand my error?</p>

<p>Note: I use Spring Boot 1.4.1 and Mongo 3.2</p>