【发布时间】:2018-06-21 12:36:16
【问题描述】:
我正在尝试使用@Query 执行系统请求。所以,我不必无缘无故地扩展 JpaRepository 并创建实体。
我收到此错误:
Field myDAO in myPackage.impl.MyService required a bean of type 'myPackage.dao.MyDAO' that could not be found.
在 MyService,我自动装配了 MyDAO。
public class MyService implements IMyService {
@Autowired
private MyDAO myDAO;
@Override
public List<String> getAllTablesName() {
return myDAO.getAllTablesName();
}
}
我尝试添加@Repository,但没有任何改变
@Repository
public interface MyService{
@Query(value ="SHOW TABLES FROM :tableName",nativeQuery = true)
public List<String> getAllTablesName(@Param("tableName") String tableName);
}
我该如何解决这个问题?
【问题讨论】:
-
我不完全确定“SHOW”命令(以及它是否可以通过 JDBC 工作),但作为表的绑定变量肯定不会工作。
标签: spring-boot spring-data-jpa