Announcement Announcement Module
Collapse
No announcement yet.
@Entity package different than the Repository packge Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • @Entity package different than the Repository packge

    Hello
    I'm new to Spring.
    I want to locate the @Entity classes in a different package (or even in a different module) than the @Repository classes.
    For some reason Spring fails to run if the @Entity and the @Repository classes are in different classes.
    The error I get is that the @Entity class is not managed class (what ever that's mean).
    I tried to use @ComponentScan from the repository classes to look for the entities classes, I tries to use @EnableAutoConfiguration in the @Entity classes, and in the repositories, but nothing.
    Only when I place the Entity and the Repository classes in the same class it works.

    Any idea of what happen behind the scene would be much appreciated.
    Thank you in advance

  • #2
    You need to configure your persistence layer correctly, I would recommend you look at the Spring documentation,
    the ORM-JPA section may be a good place to start (see: section 14.5 JPA) http://docs.spring.io/spring/docs/4....m.html#orm-jpa

    I would look at setting up a persistence.xml file and orm.xml file.

    I would also look at examples on GitHub under the spring projects. There is also some great getting started guides on spring.io @ http://spring.io/guides

    If you have more questions or need more details I would direct them to stackoverflow and add the tag "spring-data" as you will get your questions answer there as this forum is moving to Stackoverflow soon.

    Comment


    • #3
      Another option is to look at the property "packagesToScan" for LocalContainerEntityManagerFactoryBean

      Comment

      Working...
      X