user3663882
user3663882

Reputation: 7367

Inject spring bean into @Controller via applicationContext.xml

In my dispatcher-servlet.xml I defined a bean as follows:

<bean id="worplacementDAO" class="com.mycompany.maventestwebapp.db.dao">
            <property name="dataSource" value="dataSource" />
</bean>

Is it possible to inject the bean into a controller via applicationContext configuration file, without using @Autowired?

Upvotes: 1

Views: 303

Answers (1)

Pavel Horal
Pavel Horal

Reputation: 18224

Simple answer - No.

You can implement BeanPostProcessor to do something with your beans (e.g. inject dependency). Or you can manually register the bean as <bean> instead of letting component-scan do that for you. But that is all you can do.

Upvotes: 2

Related Questions