java - Spring boot @Autowired can't initialise class -


i have following class as:-

@springbootapplication @componentscan("com.ma.demospringboot") public class demospringbootapp {    public static void main(string[] args) {       springapplication.run(demospringbootapp.class, args);    } } 

i have following class as:-

@service public class topicservice {     // if comment out following autowired, ok.     @autowired     private topicrepository topicrepository;  } 

i have following interface as:-

public interface topicrepository extends  crudrepository<topic, string> { } 

i have following class as:-

@entity  public class topic {     @id     private string id;     private string name;     private string description;      public topic() {     } } 

i got following error when try execute:-


application failed start


description:

field topicrepository in com.ma.demospringboot.service.topicservice required bean of type 'com.ma.demospringboot.repository.topicrepository' not found.

action:

consider defining bean of type 'com.ma.demospringboot.repository.topicrepository' in configuration.

spring container not finding repository classes during scan, add @enablejparepositories explicitly specify packages of repository classes exist, shown below:

  @springbootapplication   @componentscan("com.ma.demospringboot")   @enablejparepositories("com.ma.demospringboot.repository")   @entityscan(basepackages = "com.ma.demospringboot.domain")   public class demospringbootapp {       //your current code here   } 

update1:

not managed type: class com.ma.demospringboot.domain.topic

now, topic entity class not found, need @entityscan(basepackages = "com.ma.demospringboot.domain") scan entity classes (as show above).

update2:

i did suggested, not working

there problem way packaging classes, double check on that, ensure latest classes have been compiled/built & used server.


Comments

Popular posts from this blog

inversion of control - Autofac named registration constructor injection -

verilog - Systemverilog dynamic casting issues -

ios - Change Storyboard View using Seague -