Spring Hibernate won't implement Repository Class from Interface -


i have 2 separate projects. 1 project contains application logic , controllers in org.patrick.application, , 1 separate project contains hibernate entities, dao, , models in org.patrick.hibernate. problem spring not instantiate implementing class crudrepository.

here application.java class annotations in application project:

package org.patrick.application;  @springbootapplication @configuration @enableautoconfiguration @enabletransactionmanagement @enablejparepositories(basepackages = { "org.patrick.hibernate" }) @entityscan(basepackages = { "org.patrick.hibernate" }) @componentscan(basepackages = { "org.patrick.hibernate", "org.patrick.application" }) 

these annotations should scan second hibernate project of hibernate objects.

my hibernate repository looks this:

package org.patrick.hibernate;  @repository public interface patrickdao extends crudrepository<mymodel, long> 

this repository not have class implementation. expecting spring populate implementation me.

now, inside of application org.patrick.application, trying use dao so:

package org.patrick.application;  @autowired private patrickdao patrickdao; 

this causing application project fail start because of following error:

caused by: org.springframework.beans.factory.nosuchbeandefinitionexception: no qualifying bean found dependency [org.patrick.hibernate.patrickdao]: expected @ least 1 bean qualifies autowire candidate. 

i know core problem spring not implementing interface - because if provide own patrickdaoimpl in org.patrick.hibernate package, application project start fine. confuses me because have proper annotations on application.java class, , yet repository cannot implemented spring reason.

is there further need in order spring implement class repository interface? in previous testing, behavior works if under same package.

i found problem. particular model, definition looked such:

package org.patrick.hibernate;  public class mymodel implements serializable {} 

this model did not have @entity annotation. if annotation missing, spring give no warnings why cannot implement repository interface. in case, threw nosuchbeandefinitionexception exception.

i updated model proper annotations:

package org.patrick.hibernate;  @entity public class mymodel implements serializable {} 

Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -