0
我正在開發一個應用程序,它具有兩個(Spring)應用程序上下文配置,一個是Java class
,另一個是xml
文件(commonApplicationContext
。xml
)。java類和xml的contextConfigLocation值
的Java類配置 - >
@Configuration
@PropertySource("classpath:apis.application.properties")
/*
* The component scan can be used to add packages and exclusions to the default
* package
*/
@ComponentScan(basePackages = {"org.surfnet.oaaas.resource", "org.surfnet.oaaas.service"})
@ImportResource("classpath:spring-repositories.xml")
@EnableTransactionManagement
public class SpringConfiguration {
}
XML配置(commonApplicationContext.xml) - >
<context:component-scan base-package="com.test.common.dao.*,org.surfnet.*">
<context:exclude-filter type="regex" expression="org\.surfnet\.*"/>
</context:component-scan>
<context:annotation-config />
<!--tx:annotation-driven transaction-manager="defaultTransactionManager"/-->
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="persistenceUnitName" value="common"/>
<property name="persistenceXmlLocation" value="classpath:META-INF/persistence.xml" />
<property name="packagesToScan" value="com.test.common.dao.entity"/>
<!--property name="jpaVendorAdapter" ref="jpaVendorAdapter"/-->
</bean>
<!--<bean id="jpaVendorAdapter" class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="showSql" value="true"/>
<property name="generateDdl" value="true"/>
<property name="database" value="MYSQL"/>
</bean>-->
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory"/>
</bean>
<bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor"/>
現在我想知道有沒有辦法在加載這兩個配置web.xml中?下面,我已經盡力了,但不工作
web.xml中的條目 - >
<context-param>
<param-name>contextClass</param-name>
<param-value>org.springframework.web.context.support.AnnotationConfigWebApplicationContext</param-value>
</context-param>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
org.surfnet.oaaas.config.SpringConfiguration
classpath:commonApplicationContext.xml
</param-value>
</context-param>