我正在尝试将库集成到另一个库中,以下代码是jpa-config.xml中的内容:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="packagesToScan" value="com.example1" />
<property name="persistenceProviderClass" value="org.eclipse.persistence.jpa.PersistenceProvider" />
<property name="dataSource" ref="dataSource" />
<property name="jpaVendorAdapter" ref="jpaAdapter" />
<property name="jpaPropertyMap">
<map>
<entry key="eclipselink.weaving" value="false" />
<entry key="eclipselink.logging.level" value="INFO" />
<entry key="eclipselink.logging.level.sql" value="INFO" />
<entry key="eclipselink.cache.shared.default" value="false" />
</map>
</property>
</bean>
</beans>
我只是想知道我是否可以做这样的事情:
<property name="packagesToScan">
<list>
<value>com.example1</value>
<value>com.example2</value>
</list>
</property>
答案 0 :(得分:0)
您可以指定多个要使用下方扫描的包(包含在您的问题中):
<property name="packagesToScan">
<list>
<value>com.example1</value>
<value>com.example2</value>
</list>
</property>
packagesToScan
属性适用于xml less配置,即。没有persistence.xml ...当使用持久性xml时,它遵循JPA规范。