spring-mvc-quickstart-archetype icon indicating copy to clipboard operation
spring-mvc-quickstart-archetype copied to clipboard

Full example for MongoDb

Open azizasm opened this issue 9 years ago • 0 comments

Appreciate if there is full example on how to configure this spring-mvc-quickstart-archetype to mongoDb.

Based on current document by adding having error : @EnableMongoRepositories(basePackageClasses = Application.class)

AccoutRepository.java

import org.springframework.data.mongodb.repository.MongoRepository;

@Repository
public interface AccountRepository extends MongoRepository<Account, Long> {
    Account findOneByEmail(String email);
}

Error:

2016-10-28 09:20:09.879 [localhost-startStop-1] ERROR o.s.web.context.ContextLoader - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scopedTarget.accountService': Invocation of init method failed; nested exception is org.springframework.dao.InvalidDataAccessApiUsageException: Can
not autogenerate id of type java.lang.Long for entity of type my.groupid.account.Account!
        at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:136)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:408)

azizasm avatar Oct 28 '16 01:10 azizasm