Note that there are some explanatory texts on larger screens.

plurals
  1. POHow does autowiring of custom spring data (mongo) repositories configured with java config work?
    primarykey
    data
    text
    <p>I use Spring Data Mongo with repositories. In my xml-configuration everything works fine. Now I want to use Java configuration instead of xml-configuration. This is my java configuration for the repositories:</p> <pre><code>@Configuration @EnableMongoRepositories public class DefaultMongoDbFactoryConfig extends AbstractMongoConfiguration{ @Value("${db.name}") private String dbName; @Inject private Mongo mongo; @Bean protected MongoDbFactory defaultMongoDbFactory() throws Exception { return new SimpleMongoDbFactory(mongo, dbName); } @Bean protected MongoTemplate defaultMongoTemplate() throws Exception { return new MongoTemplate(defaultMongoDbFactory()); } @Override protected String getDatabaseName() { return dbName; } @Override public Mongo mongo() throws Exception { return mongo; } @Override protected String getMappingBasePackage() { return "foo.bar.repository"; } @Override public MongoTemplate mongoTemplate() throws Exception { return defaultMongoTemplate(); } } </code></pre> <p>I have a repository with a custom implementation:<br> Interface: MyRepository (extends the custom interface)<br> CustomInterface: MyRepositoryCustom<br> Implementation: MyRepositoryImpl</p> <p>I have another configuration file with the component-scan annotation:</p> <pre><code>@Configuration @ComponentScan(basePackages = {"foo.bar"}) @Import(DefaultMongoDbFactoryConfig.class) public class AppConfig { } </code></pre> <p>Now spring does not seem to autowire the custom implementation on startup. I get "No qualifying bean of type". Is this not supported in java config or am I missing something?</p> <p><strong>EDIT</strong>: I'm using spring data mongo 1.3.1 and spring 3.2.4</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload