kolorobot / spring-mvc-quickstart-archetype

The project is a Maven archetype for Spring MVC web application.
http://blog.codeleak.pl
1.05k stars 478 forks source link

Guide to run with Mongodb #89

Closed haibt closed 9 years ago

haibt commented 9 years ago

Hi there,

I see we have a MongoConfig to support mongodb connection. But I could not find out the Guide to declare in persistence.properties. Could you tell me how to use the project with MongoDB.

Thanks and Best regards,

kolorobot commented 9 years ago

There is no guide :) The configuration is in place. Simply start using it. E.g. inject MongoTemplate and start calling the DB. Make sure database is running. You can also add Spring Data MongoDB dependency (http://projects.spring.io/spring-data-mongodb/). And that's it. Let me know if it works for you!

withakhil commented 8 years ago

Hi @kolorobot I was trying out the mongodb with this quickstart you have provided. Can you please give a reference to some implementation example? I am not able to connect to my mongodb. it is throwing me this error:

Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [MyRepository] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}

Here is how my repository class looks like:

@Repository
public interface MyRepository extends MongoRepository<MyRepositoryBean, Long> {
}

Please suggest any implementation, where I can refer to. Thank you.

I also tried this : https://spring.io/guides/gs/accessing-data-mongodb/#initial

withakhil commented 8 years ago

Hi @kolorobot,

I added annotation @EnableMongoRepositories in my service class to resolve the problem.

Thanks

kolorobot commented 8 years ago

@withakhil I added simple HOW-TO in README.md. Thanks!

withakhil commented 8 years ago

Hi @kolorobot , Tested, It works now. Now I don't not have to add the @EnableMongoRepositories in my service classes. Thanks!