“No persistence unit with name 'product' found”

后端 未结 4 1619
攒了一身酷
攒了一身酷 2021-01-05 00:53

I recently completed this tutorial: \"http://static.springsource.org/docs/Spring-MVC-step-by-step/\", but now I want it to work with Hibernate and annotations. I know I\'m c

相关标签:
4条回答
  • 2021-01-05 01:24

    i have the same problem. But when you use the ide(for example eclipse) and configure your server in the ide. When you asosiate the piece and restart the server always have the same error because detected the persistence unit is used, you need delete that part of the server and deploy to the oldway. Enter to the console and install the peace of you project and works!!

    And the other is when you check the diagnostic in wls you need said who user is the owner of the jdbc, only select and check (for example, AdminServer) and save and check again!!

    :D

    0 讨论(0)
  • 2021-01-05 01:39

    You need a META-INF/persistence.xml, with <persistence-unit name="product">. See here

    (I usually put it in WEB-INF/classes/META-INF. As noted in the comments, with maven you can place it in src/main/resources/META-INF)

    0 讨论(0)
  • 2021-01-05 01:39

    I run onto the same problem and had to manually edit the Web Deployment Assembly Configuration so as to instruct /META-INF/persistence.xml to be deployed under WEB-INF/classes/ (the red box in the attached img was manually edited)

    0 讨论(0)
  • this is a example of file persistence.xml

    <persistence xmlns="http://java.sun.com/xml/ns/persistence"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
             version="2.0">
    <persistence-unit name="poduct"  transaction-type="RESOURCE_LOCAL">
    </persistence-unit>
    </persistence>
    

    create this file inside "src/main/resources/META-INF" if you use Maven project.

    0 讨论(0)
提交回复
热议问题