How to Pass Multiple Packages to packagesToScan property in Spring using XML Configuration

一笑奈何 提交于 2019-12-03 06:30:46

问题


Assume i have two packages com.test1 and com.test2 in different modules called M1 (com.test1) and M2 (com.test2).

Now in the following example i configured module1 package.

<bean id="entityManager" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">        
       <property name="packagesToScan" value="com.test1" />
       <property name="dataSource" ref="dataSource" />
       <property name="jpaVendorAdapter" ref="hibernateVendor" />
       <property name="jpaPropertyMap" ref="jpaPropertyMap" />
   </bean>

But i want to configure Module2 package as well in packagesToScan property. How to configure.


回答1:


I found answer my self.

<bean id="entityManager" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">        
     <property name="packagesToScan">
         <array>
              <value>com.test1</value>
              <value>com.test2</value>
         </array>
     </property>       
     <property name="dataSource" ref="dataSource" />
     <property name="jpaVendorAdapter" ref="hibernateVendor" />
     <property name="jpaPropertyMap" ref="jpaPropertyMap" />
</bean>


来源:https://stackoverflow.com/questions/26886843/how-to-pass-multiple-packages-to-packagestoscan-property-in-spring-using-xml-con

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!