Now, let's start the application by running ./gradlew clean bootRun in order to verify that we will still see the same output in the console logs as we did in the previous recipe
If we start the application with the DEBUG switch so as to see the Auto-Configuration Report, which we already learned in the first recipe of this chapter, we will see that our autoconfiguration is in the Positive Matches group, as follows:
DbCountAutoConfiguration#dbCountRunner - @ConditionalOnMissingBean (types: com.example.bookpubstarter.dbcount.DbCountRunner; SearchStrategy: all) found no beans (OnBeanCondition)
Let's explicitly/manually create an instance of DbCountRunner in our main BookPubApplication configuration class, and we will also override its run(...) method, just so we can see the difference in the logs:
protected final Log logger = LogFactory.getLog(getClass());
@Bean
public DbCountRunner dbCountRunner (Collection<CrudRepository> repositories) {
return new DbCountRunner(repositories) {
@Override
public void run(String... args) throws Exception {
logger.info("Manually Declared DbCountRunner");
}
};
}
Start the application by running DEBUG=true ./gradlew clean bootRun.
If we look at the console logs, we will see two things: the Auto-Configuration Report will print our autoconfiguration in the Negative Matches group and, instead of the count output for each repository, we will see Manually Declared DbCountRunner text to appear:
DbCountAutoConfiguration#dbCountRunner - @ConditionalOnMissingBean (types: com.example.bookpubstarter.dbcount.DbCountRunner; SearchStrategy: all) found the following [dbCountRunner] (OnBeanCondition)2017-12-16 INFO com.example.bookpub.BookPubApplication$1 : Manually Declared DbCountRunner