JPA에서 MySql 데이터베이스를 사용하고 있습니다. 난 항상 다시 널 올자바 영속성 엔티티 관리자 팩토리가 null을 반환합니다.
EntityManagerFactory emf = Persistence.createEntityManagerFactory("citheph");
EntityManager em = emf.createEntityManager();
기전력을 다음을 수행 내 자바 코드에
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0"
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">
<persistence-unit name="citheph">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>persistence.citheph.pTerm</class>
<class>persistence.citheph.pPublicationterm</class>
<class>persistence.citheph.pPublicationauthor</class>
<class>persistence.citheph.pPublication</class>
<class>persistence.citheph.pCoauthorship</class>
<class>persistence.citheph.pCitation</class>
<class>persistence.citheph.pAuthor</class>
<properties>
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/cithepth" />
<property name="javax.persistence.jdbc.password" value="amer1" />
<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" />
<property name="javax.persistence.jdbc.user" value="root" />
</properties>
</persistence-unit>
</persistence>
처럼 내 persistence.xml을 보인다. 데이터베이스가 연결되고 성공적으로 핑합니다. persistance.xml의 항목과 일치하지 않는 항목으로 persistence-unit 이름을 변경하려고 시도했지만 여전히 null이 표시됩니다. 예외를 던지지는 않습니다. 코드의 두 번째 줄에 도착하면 당연히
EntityManager em = emf.createEntityManager();
널 포인터 예외가 발생합니다.
어떤 도움을 주시면 대단히 감사하겠습니다.
에 감사드립니다. 나는 eclips보다 하나의 persistence claases를 위해 다른 라이브러리를 사용하고 있었다. 시간 내 주셔서 감사합니다 – Amer
어떻게 로깅을 최우선으로 설정합니까? –