Unzufrieden Abhängigkeit ausgedrückt durch das Feld (Frühling-Boot v 1.5.1)
Ich bin Neuling in spring boot und mongoDB bitte helfen.
Ich bin immer unsatified dependcy ausgedrückt durch mongoTemplate, ich bin nicht in der Lage zu finden, die Ursache von ihm. Unten ist die stack-Spur.
"org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'gmailPullHandler': Unsatisfied dependency expressed through field 'gmailPullService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'gmailPullService': Unsatisfied dependency expressed through field 'gmailMailDataRepository'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'gmailMailDataRepositoryImpl': Unsatisfied dependency expressed through field 'mongoTemplate'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'mongoTemplate' defined in class path resource [org/springframework/boot/autoconfigure/data/mongo/MongoDataAutoConfiguration.class]: Unsatisfied dependency expressed through method 'mongoTemplate' parameter 1; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'mappingMongoConverter' defined in class path resource [org/springframework/boot/autoconfigure/data/mongo/MongoDataAutoConfiguration.class]: Unsatisfied dependency expressed through method 'mappingMongoConverter' parameter 1; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mongoMappingContext' defined in class path resource [org/springframework/boot/autoconfigure/data/mongo/MongoDataAutoConfiguration.class]: Invocation of init method failed; nested exception is java.lang.StackOverflowError
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:588)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:366)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1264)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:866)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:542)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:737)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:370)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:314)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1162)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1151)
at com.plash.configurator.Application.main(Application.java:38)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:50)
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51)
Da gibt es die drei ungelösten Abhängigkeit, die man verursacht Fehler, ich bin nicht in der Lage, es zu finden.
HINWEIS: gmailMailDataRepository Klasse erweitert MongoRepository, GmailMailDataRepositoryCustom
gmailMailDataRepository :
@Repository
public interface GmailMailDataRepository extends MongoRepository<GmailMailData, String>, GmailMailDataRepositoryCustom {
{'threadidslist.threadid':?1}{'useremail':?2}")
List<GmailMailData> getListByThreadidmMsgidEmailid(String messagid, String threadid, String useremail);
void saveObjectToMsgList(GmailMessages gm, String useremailid, String threadid, String prospectemailid);
}
Unten ist GmailMailDataRepositoryCustom und GmailMailDataRepositoryImpl:
GmailMailDataRepositoryCustom:
public interface GmailMailDataRepositoryCustom {
void saveObjectToMsgList(GmailMessages g, String useremailid, String threadid, String prospectemailid);
}
GmailMailDataRepositoryImpl:
public class GmailMailDataRepositoryImpl implements GmailMailDataRepositoryCustom {
//private final MongoOperations operations;
@Autowired
private MongoTemplate mongoTemplate;
Update update = new Update();
@Override
public void saveObjectToMsgList(GmailMessages gm, String useremailid, String threadid, String prospectemailid) {
Query query = new Query(Criteria.where("useremail").is(useremailid).and("prospectemailid").is(prospectemailid).and("threadidslist.threadid").is(threadid));
update.push("threadidslist.$.messagelist", gm);
mongoTemplate.updateFirst(query, update, GmailMailData.class);
}
Anwendung.properities Konfiguration für mongo ist wie folgt:
spring.data.mongodb.host=localhost
spring.data.mongodb.password=#########
spring.data.mongodb.port=27017
spring.data.mongodb.repositories.enabled=true
bauen.gradle:
compile("org.springframework.boot:spring-boot-starter-data-mongodb")
- Problem scheint zu sein, die Injektion
pullhandler
benannte variable inpullshandlerservice
. Hinzufügen Sie können diese Klassen in der post ? - Die Ursache scheint tatsächlich so zu sein
StackOverflowError
in der init-MethodeMongoDataAutoConfiguration
. Vielleicht nehmen Sie einen Blick auf die Quellen dieser Klasse enthüllt ein paar weitere Einblicke?! - Ich habe nicht explicitally Konfiguriert mongo Eigenschaften, alles liegt unter application.class wo EnableAutoConfiguration ist schon da.
- Ich habe versucht, zu kommentieren pullshandlerservice, aber jetzt Fehler Bewerbung von wo auch immer, dass GmailMailDataRepository verwendet wird
- Die automatische Verdrahtung ist nicht korrekt arbeiten. Stellen Sie sicher, dass Ihre Klassen sind definiert in den packages, wo der Frühling ist, Scannen Sie Sie.
- Ich re-aktiviert seinen Platz.
- Warum definierst du
void saveObjectToMsgList(GmailMessages gm, String useremailid, String threadid, String prospectemailid);
imGmailMailDataRepository
wenn es schon inGmailMailDataRepositoryCustom
(die extended vonGmailMailDataRepository
)? Entfernen Sie es ausGmailMailDataRepository
- Danke für die Korrektur mich. Anyways ich gelöst der Fehler war es in der modelclass.
- Vielleicht könnten Sie fügen Sie Ihre Korrektur als Antwort auf deine eigene Frage? Dies könnte helfen, die Menschen, die sich begegnen das selbe problem wie du habe, als das Update scheint nicht zu offensichtlich...
Du musst angemeldet sein, um einen Kommentar abzugeben.
Problem gelöst. Es war das Modell-level-Fehler.
Casting-Liste falsch war.
Ich soll cast GmailOtherThreads Objekt in der Liste, aber ich war mit einem anderen Objekt zu. Wegen der falschen casting war ich immer Fehler überall im code.