java - Bean not autowiring -



java - Bean not autowiring -

i have application-context.cml:

<?xml version="1.0" encoding="utf-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemalocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd" default-autowire="bytype"> <context:annotation-config /> <tx:annotation-driven /> <bean class="app.bl.facade.impl.dishfacadeimpl" />

and attempting autowire it:

@autowired private dishfacade dishfacade; public list<dish> getevents() { system.out.println(dishfacade); homecoming dishfacade.getall(); }

the result printed out null, i'm unable figure out why though.

assuming bundle app.bl.facade have place tag in application-context.xml

<context:component-scan base-package="app.bl.facade" />

above xml tag perform auto scanning. each class should created bean annotated right stereotype annotation @component (for general bean) or @controller (for servlet controllers) or @repository (for dao classes) or @service , these classes should placed under same base of operations bundle app.bl.facade.

if above criteria met, spring automatically find of these , create bean each one.

java spring

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -