首页 文章

带 spring 启动的通用jpa存储库

提问于
浏览
0

我试图使用通用的Jpa规格与 spring 启动,但出现了这个问题 .

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2018-05-23 18:18:27.340 ERROR 1048 --- [  restartedMain] o.s.boot.SpringApplication               : Application run failed

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jpaSpecificationRepository': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Not a managed type: class java.lang.Object.

在我的代码中我正在尝试使用模块概念,所以我有5个模块(实体,dao,服务,web和frontend with angular)所以这是我的代码:

我的通用Jpa规范界面 .

public interface JpaSpecificationRepository<T, ID extends Serializable>
        extends JpaRepository<T, ID>, JpaSpecificationExecutor<T> {

}

存储库的例子 .

public interface HelloRepository extends JpaSpecificationRepository<Hello, Long> {

}

服务

@Service
public class HelloServiceImpl extends AbstractCRUDService<Hello, Long, HelloDto> {

    @Autowired
    protected HelloServiceImpl(HelloRepository repository, DozerBeanMapper mapper) {
        super(repository, mapper, Hello.class, HelloDto.class);
    }
}

和控制器

@RestController
@CrossOrigin("*")
@RequestMapping("/hello")
public class HelloController extends AbstractCRUDBackOfficeController<Long, HelloDto> {

    @Autowired
    HelloController(HelloServiceImpl service) {
        super(service);
    }
}

1 回答

  • 1

    @NoRepositoryBean 添加到 JpaSpecificationRepository ,这样就可以排除此存储库的实例化 .

相关问题