0
***************************
APPLICATION FAILED TO START
***************************

Description:

Parameter 0 of method saveData in com.example.SpringBootJournalApplication required a bean of type 'repository.JournalRepository' that could not be found.


Action:

Consider defining a bean of type 'repository.JournalRepository' in your configuration.

When i run the project Spring fails to start and i have this error.

This is the SpringApplication.run class, all dependencies are properly defined in the pom.xml and downloaded.

@SpringBootApplication
public class SpringBootJournalApplication {

@Bean
InitializingBean saveData(JournalRepository repo){
    return ()->{
        repo.save(new Journal("text1",LocalDate.now(),"date1"));
        repo.save(new Journal("text2",LocalDate.now(),"date2"));
        repo.save(new Journal("text3",LocalDate.now(),"date3"));
        repo.save(new Journal("text4",LocalDate.now(),"date4"));
    };
}

public static void main(String[] args) {
    SpringApplication.run(SpringBootJournalApplication.class, args);
}
}
Maver
  • 77
  • 1
  • 11
  • 1
    Your answer is found here: http://stackoverflow.com/questions/40384056/consider-defining-a-bean-of-type-package-in-your-configuration-spring-boot – user3272686 Feb 08 '17 at 17:25
  • Have you annotated your JournalRepository properly? – Coder Feb 08 '17 at 17:28
  • 1
    Thanks, i had the classes in different packages, moving all in the same fixed the problem – Maver Feb 08 '17 at 17:34

0 Answers0