Parameter 0 of constructor in required a bean of type 'java.lang.String' that could not be found

前端 未结 10 2487
深忆病人
深忆病人 2021-02-07 01:41

I am working on spring batch with spring boot 2.X application, actually its existing code i am checked out from git. While running the application it fails due to below error on

10条回答
  •  庸人自扰
    2021-02-07 02:07

    I also had the same error:

    ***************************
    APPLICATION FAILED TO START
    ***************************
    
    Description:
    
    Field repository in com.example.controller.CampaignController required a bean of type 'com.example.data.CustomerRepository' that could not be found.
    
    
    Action:
    
    Consider defining a bean of type 'com.example.data.CustomerRepository' in your configuration.de here
    

    I solved this issue by adding @EnableMongoRepositories annotation in the main class:

    @SpringBootApplication
    @EnableMongoRepositories(basePackageClasses = CustomerRepository.class)
    public class CampaignAPI {
    
        public static void main(String[] args) {
            SpringApplication.run(CampaignAPI.class, args);
        }
    }
    

提交回复
热议问题