简体   繁体   English

无法在春季启动中创建Bean

[英]Unable to create bean in spring boot

I am getting this 我得到这个

Error creating the bean with name 'listsServiceImpl': Unsatisfied dependency expressed through field 'listRepo' 创建名称为“ listsServiceImpl”的bean时出错:通过字段“ listRepo”表示的依赖关系不令人满意

every time I run my project, I get this error.I started playing with spring boot following this 每次我运行项目时,都会出现此错误。

http://www.baeldung.com/spring-data-couchbase http://www.baeldung.com/spring-data-couchbase

ListRepository.java ListRepository.java

package com.test.example.repo;   
import org.springframework.data.repository.CrudRepository; 
import com.test.example.entity.Lists;

public interface ListsRepository extends CrudRepository<Lists,String>{
  }

ListsService.java ListsService.java

package com.test.example.service; 包com.test.example.service; import com.test.example.entity.Lists; 导入com.test.example.entity.Lists;

public interface ListsService { 
   void create(Lists list);     boolean
   checkListName(String listName, String userId); 
}

ListsServiceImpl ListsServiceImpl

package com.test.example.service;
import org.springframework.beans.factory.annotation.Autowired; 
import org.springframework.stereotype.Service;
import com.test.example.entity.Lists;
import com.test.example.repo.ListsRepository;

@Service 
public class ListsServiceImpl implements ListsService{

 @Autowired     
 private ListsRepository listRepo;

 @Override  
 public void create(Lists list) {       
         listRepo.save(list);   
 }

  @Override     
  public boolean checkListName(String listName, String userId) {        
      // TODO Auto-generated method stub        
     return false;  
    } 

} }

add

@ComponentScan("com.test.example") @ComponentScan(“ com.test.example”)

in your main application class. 在您的主应用程序类中。

只需将@EnableJpaRepositories批注添加到您的配置类。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法在spring boot中定义bean - Unable to define bean in spring boot 无法在Spring Boot中初始化Bean - Unable to initialize bean in spring boot spring boot - 在同一线程上创建和销毁 bean - spring boot - create and destroy bean on the same thread 创建在外部 jar spring 引导中配置的 bean - Create bean configured in external jar spring boot Spring 启动:在运行时创建配置属性 bean - Spring boot: create configuration properties bean in runtime 无法创建配置,因为找不到 Bean 验证提供程序 - Vaadin 14 Spring Boot - Unable to create a Configuration, because no Bean Validation provider could be found - Vaadin 14 Spring Boot 如何在spring boot中使用@Bean为抽象类创建bean - How to create bean using @Bean in spring boot for abstract class Spring 引导:无法访问 Spring 调度程序中的请求 scope bean - Spring Boot: Unable to access the request scope bean in Spring Scheduler Spring Boot:由于缺少 EmbeddedServletContainerFactory bean 无法启动 EmbeddedWebApplicationContext - Spring Boot: Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean 由于缺少 EmbeddedServletContainerFactory bean,Spring Boot 无法启动 EmbeddedWebApplicationContext - Spring Boot Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM