java - Spring boot Autowired Mongo Repository not working -


i trying connect spring boot application mongo db follwoing this tutorial. pretty simple, have class scanresults objects trying save in db when receive post request. following error on autowired.

exception in thread "main" org.springframework.beans.factory.beancreationexception: error creating bean name 'application': injection of autowired dependencies failed; nested exception org.springframework.beans.factory.beancreationexception: not autowire field: public com.gandharv.iiitd.scanresultsrepository com.gandharv.iiitd.application.repository; nested exception org.springframework.beans.factory.beancreationexception: error creating bean name 'scanresultsrepository': invocation of init method failed; nested exception org.springframework.data.mapping.model.mappingexception: not lookup mapping metadata domain class java.lang.object! @ org.springframework.beans.factory.annotation.autowiredannotationbeanpostprocessor.postprocesspropertyvalues(autowiredannotationbeanpostprocessor.java:292) @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.populatebean(abstractautowirecapablebeanfactory.java:1185) @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.docreatebean(abstractautowirecapablebeanfactory.java:537) @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.createbean(abstractautowirecapablebeanfactory.java:475) @ org.springframework.beans.factory.support.abstractbeanfactory$1.getobject(abstractbeanfactory.java:302) @ org.springframework.beans.factory.support.defaultsingletonbeanregistry.getsingleton(defaultsingletonbeanregistry.java:228) @ org.springframework.beans.factory.support.abstractbeanfactory.dogetbean(abstractbeanfactory.java:298) @ org.springframework.beans.factory.support.abstractbeanfactory.getbean(abstractbeanfactory.java:193) @ org.springframework.beans.factory.support.defaultlistablebeanfactory.preinstantiatesingletons(defaultlistablebeanfactory.java:703) @ org.springframework.context.support.abstractapplicationcontext.finishbeanfactoryinitialization(abstractapplicationcontext.java:760) @ org.springframework.context.support.abstractapplicationcontext.refresh(abstractapplicationcontext.java:482) @ org.springframework.boot.context.embedded.embeddedwebapplicationcontext.refresh(embeddedwebapplicationcontext.java:120) @ org.springframework.boot.springapplication.refresh(springapplication.java:691) @ org.springframework.boot.springapplication.run(springapplication.java:320) @ org.springframework.boot.springapplication.run(springapplication.java:952) @ org.springframework.boot.springapplication.run(springapplication.java:941) @ com.gandharv.iiitd.application.main(application.java:21) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:57) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) @ java.lang.reflect.method.invoke(method.java:606) @ com.intellij.rt.execution.application.appmain.main(appmain.java:134) caused by: org.springframework.beans.factory.beancreationexception: not autowire field: public com.gandharv.iiitd.scanresultsrepository com.gandharv.iiitd.application.repository; nested exception org.springframework.beans.factory.beancreationexception: error creating bean name 'scanresultsrepository': invocation of init method failed; nested exception org.springframework.data.mapping.model.mappingexception: not lookup mapping metadata domain class java.lang.object! @ org.springframework.beans.factory.annotation.autowiredannotationbeanpostprocessor$autowiredfieldelement.inject(autowiredannotationbeanpostprocessor.java:508) @ org.springframework.beans.factory.annotation.injectionmetadata.inject(injectionmetadata.java:87) @ org.springframework.beans.factory.annotation.autowiredannotationbeanpostprocessor.postprocesspropertyvalues(autowiredannotationbeanpostprocessor.java:289) ... 21 more  caused by: org.springframework.beans.factory.beancreationexception: error creating bean name 'scanresultsrepository': invocation of init method failed; nested exception org.springframework.data.mapping.model.mappingexception: not lookup mapping metadata domain class java.lang.object! @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.initializebean(abstractautowirecapablebeanfactory.java:1553) @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.docreatebean(abstractautowirecapablebeanfactory.java:539) @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.createbean(abstractautowirecapablebeanfactory.java:475) @ org.springframework.beans.factory.support.abstractbeanfactory$1.getobject(abstractbeanfactory.java:302) @ org.springframework.beans.factory.support.defaultsingletonbeanregistry.getsingleton(defaultsingletonbeanregistry.java:228) @ org.springframework.beans.factory.support.abstractbeanfactory.dogetbean(abstractbeanfactory.java:298) @ org.springframework.beans.factory.support.abstractbeanfactory.getbean(abstractbeanfactory.java:193) @ org.springframework.beans.factory.support.defaultlistablebeanfactory.findautowirecandidates(defaultlistablebeanfactory.java:1017) @ org.springframework.beans.factory.support.defaultlistablebeanfactory.doresolvedependency(defaultlistablebeanfactory.java:960) @ org.springframework.beans.factory.support.defaultlistablebeanfactory.resolvedependency(defaultlistablebeanfactory.java:858) @ org.springframework.beans.factory.annotation.autowiredannotationbeanpostprocessor$autowiredfieldelement.inject(autowiredannotationbeanpostprocessor.java:480) ... 23 more caused by: org.springframework.data.mapping.model.mappingexception: not lookup mapping metadata domain class java.lang.object! @ org.springframework.data.mongodb.repository.support.mongorepositoryfactory.getentityinformation(mongorepositoryfactory.java:144) @ org.springframework.data.mongodb.repository.support.mongorepositoryfactory.gettargetrepository(mongorepositoryfactory.java:83) @ org.springframework.data.repository.core.support.repositoryfactorysupport.getrepository(repositoryfactorysupport.java:158) @ org.springframework.data.repository.core.support.repositoryfactorybeansupport.initandreturn(repositoryfactorybeansupport.java:224) @ org.springframework.data.repository.core.support.repositoryfactorybeansupport.afterpropertiesset(repositoryfactorybeansupport.java:210) @ org.springframework.data.mongodb.repository.support.mongorepositoryfactorybean.afterpropertiesset(mongorepositoryfactorybean.java:108) @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.invokeinitmethods(abstractautowirecapablebeanfactory.java:1612) @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.initializebean(abstractautowirecapablebeanfactory.java:1549) ... 33 more 

scanresults.java

public class scanresults {  @id private string id;  public scanresults() {}  public string getlongitude() {     return longitude; }  public string getlatitude() {     return latitude; }  public arraylist<wifiscans> getwifiscan() {     return wifiscan; }  public void setlatitude(string latitude) {     this.latitude = latitude; }  public void setlongitude(string longitude) {     this.longitude = longitude; }  public void setwifiscan(arraylist<wifiscans> wifiscan) {     this.wifiscan = wifiscan; }  private string latitude; private string longitude; public arraylist<wifiscans> wifiscan = new arraylist<wifiscans>();     } 

repository interface

package com.gandharv.iiitd; /** * created gandharvk on 4/1/2015. */  import com.gandharv.iiitd.scanresults; import org.springframework.boot.autoconfigure.enableautoconfiguration; import org.springframework.context.annotation.componentscan; import org.springframework.context.annotation.configuration; import org.springframework.data.mongodb.repository.mongorepository; import org.springframework.data.mongodb.repository.config.enablemongorepositories; import org.springframework.stereotype.repository;  public interface scanresultsrepository extends mongorepository {   scanresults find(wifiscans obj); } 

application.java

package com.gandharv.iiitd;  import org.springframework.beans.factory.annotation.autowired; import org.springframework.boot.springapplication; import org.springframework.boot.autoconfigure.enableautoconfiguration; import org.springframework.context.annotation.componentscan; import org.springframework.context.annotation.configuration; import com.gandharv.iiitd.scanresultsrepository; /**  * created gandharvk on 3/27/2015.  */ @configuration @enableautoconfiguration @componentscan public class application {      @autowired     public scanresultsrepository repository;      public static void main(string[] args) {         springapplication.run(application.class, args);     } } 

pom.xml

<parent>     <groupid>org.springframework.boot</groupid>     <artifactid>spring-boot-starter-parent</artifactid>     <version>1.1.5.release</version> </parent>  <groupid>com.gandharvkapoor</groupid> <artifactid>spring-wifi-scan</artifactid> <version>1.0-snapshot</version>  <dependencies>     <dependency>         <groupid>org.springframework.boot</groupid>         <artifactid>spring-boot-starter-web</artifactid>     </dependency>     <!-- spring data mongodb-->     <dependency>         <groupid>org.springframework.data</groupid>         <artifactid>spring-data-mongodb</artifactid>     </dependency> </dependencies>  <build>     <plugins>         <!-- spring boot maven support -->         <plugin>             <groupid>org.springframework.boot</groupid>             <artifactid>spring-boot-maven-plugin</artifactid>         </plugin>     </plugins> </build> 

okay solved commenting out find method in repository. guess compulsory implement methods of interface.


Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -