0

I have two ApplicationContexts for my project (very huge project). One old xml with data

<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"> <beans default-autowire="autodetect"> </beans> 

now I need to add my other project applicatinContext to it or any other way so that none of the modules will be impacted

<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"> <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" 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"> <bean id="positionResponsesDAO" class="com.xxx.modules.worklist.DAO.Impl.PositionResponsesDAOImpl"> <property name="dataSource" ref="dataSource" /> </bean> <bean id="positionDAO" class="com.xxx..modules.worklist.DAO.Impl.PositionDAOImpl"> <property name="dataSource" ref="dataSource" /> </bean> <bean id="nextActionDAO" class="com.xxx..modules.worklist.DAO.Impl.NextActionDAOImpl"> <property name="dataSource" ref="dataSource" /> </bean> <bean> ....... few more </bean> <bean id="workOrderManager" class="com.xxx.modules.worklist.action.manager.impl.WorkOrderManagerImpl"> <property name="positionDO" ref="positionDO" /> <property name="moveWorkOrderDO" ref="moveWorkOrderDO" /> <property name="nextActionDO" ref="nextActionDO" /> <property name="positionDAO" ref="positionDAO" /> <property name="moveResponsesDAO" ref="moveResponsesDAO" /> <property name="moveWorkOrderDAO" ref="moveWorkOrderDAO" /> <property name="nextActionDAO" ref="nextActionDAO" /> <property name="positionResponsesDAO" ref="positionResponsesDAO" /> </bean> <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close"> <property name="driverClass" value="oracle.jdbc.driver.OracleDriver" /> <property name="jdbcUrl" value="driverUrl" /> <property name="user" value="MCMGR" /> <property name="password" value="MC123" /> </bean> </beans> 

the first one has Auto-wiring enabled and this one has and needs manual wiring. How can i combined both of them to put into one xml or read two configurations.

2 Answers 2

3

I don't see why reading two or more application context files is difficult. The usual Spring idiom is to partition configuration according to layer. I typically have configuration for persistence, service, web, etc. If it's a web application, I just add all of them in using the ContextLoaderListener. You can specify as many configuration files as you need.

I would consider one huge configuration file a liability in the same way that I would look down on one huge class for everything. Decomposition is a computer science fundamental. I'd recommend partitioning your configuration.

Mixing annotation-based and XML-based configuration isn't a problem, either.

You'll only have an issue if the two configurations overlap. You'll have to remove one or the other for the conflicted beans.

Sign up to request clarification or add additional context in comments.

1 Comment

I don't know what "without success" looks like.
1

You can use the <import/> tag. See http://forum.springsource.org/showthread.php?41811-Application-Context-and-include

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.