簡體   English   中英

無法在春季啟動中創建Bean

[英]Unable to create bean in spring boot

我得到這個

創建名稱為“ listsServiceImpl”的bean時出錯:通過字段“ listRepo”表示的依賴關系不令人滿意

每次我運行項目時,都會出現此錯誤。

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

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

包com.test.example.service; 導入com.test.example.entity.Lists;

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

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;  
    } 

}

@ComponentScan(“ com.test.example”)

在您的主應用程序類中。

只需將@EnableJpaRepositories批注添加到您的配置類。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM