저는 봄과 JPA 프로젝트에 참여하고 있습니다. Persistence.xml에서 JPA Persistence Unit을 구성했으며 여기에 스프링 구성 파일이 있습니다.스프링은 현재 persistenceUnitName을 어떻게 감지합니까?
내 응용 프로그램은 정상적으로 작동하지만 Spring Framework에서 Persistence.xml 파일에 정의 된 Persistence Unit을 감지하고 Spring Bean 구성 파일에 정의되지 않은 상태로 삽입하는 방식을 이해하지 못했습니다.
아무에게도 대답 해 줄 수 있습니까?
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
<context:annotation-config/>
<context:component-scan base-package="ma.professionalpartners.fireAppBusiness.dao"/>
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean">
<property name="persistenceUnitName" value="fireApp-Domain" />
</bean>
<bean id="jpaTransactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>
<tx:annotation-driven transaction-manager="jpaTransactionManager" />
</beans>
답장을 보내 주셔서 감사합니다. 그렇습니다.하지만 스프링 구성 파일에 id = "fireApp-Domain"이라는 빈을 정의하지 않았습니다. 단지 persistence.xml에있는 PU의 이름 일뿐입니다. Persistence.xml과 스프링 구성 파일 사이에 어떤 관계가 있습니까? –
빈을 정의 할 필요가 없습니다. Spring은 기본 위치 (META-INF/persistence.xml)에서 persistence.xml을 찾는다. 지정한 이름으로 지속성 단위를 찾으면 생성합니다. – dunni