Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/http/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 当我添加新的存储库和服务时,SpringFramework bean工厂不满意_Java_Spring - Fatal编程技术网

Java 当我添加新的存储库和服务时,SpringFramework bean工厂不满意

Java 当我添加新的存储库和服务时,SpringFramework bean工厂不满意,java,spring,Java,Spring,我在spring框架中仍然是新手。我的客户端使用SpringFramework+boot+swagger 我尝试将新Dao添加为存储库,如下所示: package com.api.elastic.repository; import java.util.List; import com.api.elastic.entity.Terminal; public interface TerminalDao { public boolean isExist(String p_index);

我在spring框架中仍然是新手。我的客户端使用SpringFramework+boot+swagger

我尝试将新Dao添加为存储库,如下所示:

package com.api.elastic.repository;

import java.util.List;

import com.api.elastic.entity.Terminal;

public interface TerminalDao {
    public boolean isExist(String p_index);
    public List<Terminal> findById();
    public List<Terminal> findAll();
    public List<String> getDataByDatabaseId(Integer id);

}
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'terminalService': Unsatisfied dependency expressed through field 'terminalDao'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'id.co.bca.api.elastic.repository.TerminalDao' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
老实说,我试过谷歌,但在这个项目中没有pom.xml


那么如何解决这个问题呢?

您定义了一个名为
TerminalDAO
的接口,但是没有实现这个类

你应该有这样的东西

@Component
class TerminalDaoImpl implements TerminalDao {
 public ....
}

请记住,如果您试图使用Spring数据,您应该以另一种方式执行此操作,只需遵循

上的文档即可。您定义了一个名为
TerminalDAO
的接口,但没有此类的实现

你应该有这样的东西

@Component
class TerminalDaoImpl implements TerminalDao {
 public ....
}

请记住,如果您试图使用Spring数据,您应该以另一种方式进行,只需遵循Dao中的文档,您需要扩展其中一个存储库。
crudepository
JPARepository

public interface TerminalDao extends CrudRepository<Terminal,Integer> {
    public boolean isExist(String p_index);
    public List<Terminal> findById();
    public List<Terminal> findAll();
    public List<String> getDataByDatabaseId(Integer id);

}
公共接口终端DAO扩展了CrudRepository{
公共布尔isExist(字符串p_索引);
公共列表findById();
公共列表findAll();
公共列表getDataByDatabaseId(整数id);
}

在Dao中,您需要扩展一个存储库。
crudepository
JPARepository

public interface TerminalDao extends CrudRepository<Terminal,Integer> {
    public boolean isExist(String p_index);
    public List<Terminal> findById();
    public List<Terminal> findAll();
    public List<String> getDataByDatabaseId(Integer id);

}
公共接口终端DAO扩展了CrudRepository{
公共布尔isExist(字符串p_索引);
公共列表findById();
公共列表findAll();
公共列表getDataByDatabaseId(整数id);
}