In meinem SpringBoot 1.5.1 Projekt habe ich folgende Maven Abhängigkeit hinzugefügt:Frühlings-Boot 1.5.1, Spring Data MongoDB Keine Warte Bohne für Endlager
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
und erstellt eine Spring Data MongoDB-Repository:
package com.example.domain.repository.decision.parameter;
@Repository
public interface CustomerRepository extends MongoRepository<DecisionAnalysisParameter, String> {
}
Das ist mein Modell:
@Document(collection = "decision_analysis_parameter")
public class DecisionAnalysisParameter implements Serializable {
private static final long serialVersionUID = 1493180175756424789L;
@Id
private String id;
@NotNull
private Long decisionId;
private Set<BaseQuery> characteristicFilterQueries;
private Set<Long> sortCriteriaIds;
private Direction sortWeightCriteriaDirection;
private Direction sortTotalVotesCriteriaDirection;
private Map<String, Double> sortCriteriaCoefficients;
private Long sortCharacteristicId;
private Direction sortCharacteristicDirection;
private String sortDecisionPropertyName;
private Direction sortDecisionPropertyDirection;
private Set<Long> excludeChildDecisionIds;
private Set<Long> includeChildDecisionIds;
private Long userId;
private Integer pageNumber;
private Integer pageSize;
...
}
Im Moment kann ich
erfolgreich injizieren@Autowired
private MongoTemplate mongoTemplate;
und mit einer Sammlung über dieses Objekt arbeiten.
Aber meine Anwendung schlägt fehl, wenn ich spritze versuchen:
@Autowired
private CustomerRepository customerRepository;
mit folgenden Ausnahme:
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.example.CustomerRepository' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1486)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1104)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1066)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:585)
... 56 common frames omitted
Dies ist meine Konfigurationsklassen:
@Configuration
@ComponentScan("com.example")
@EnableMongoRepositories(basePackages = "com.example.domain.repository")
@SpringBootApplication
public class TestConfig {
}
Auch ich benutze Neo4j-Repositories, die gut funktionieren. Wie man es repariert ?