1. 程式人生 > >呼叫EntityManager出現The import javax.persistence cannot be resolved

呼叫EntityManager出現The import javax.persistence cannot be resolved

1.編寫程式碼時無法匯入import javax.persistence.EntityManager,剛開始還以為是自己的jdk1.7所以沒有,百度後在StackOverFLow瞭解到需要jar包或者JPA API.像是JPA interfaces (Hibernate, EclipseLink, OPenJPA.)等.由於是用的maven所以直接匯入對應的依賴就可以了

        <dependency>
            <groupId>org.eclipse.persistence</groupId>
            <artifactId
>
org.eclipse.persistence.jpa</artifactId> <version>2.6.0</version> </dependency>