[英]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.