2013年10月5日星期六

Spring into question .

Error message is as follows :


SyllabusService.java seventy seventh line is as follows :

output jsoupService when displayed as NULL




//SyllabusService.java中
        private JsoupService jsoupService;
public JsoupService getJsoupService() {
return jsoupService;
}

@Resource(name ="jsoupService")
public void setJsoupService(JsoupService jsoupService) {
this.jsoupService = jsoupService;
}



//JsoupService.java中
@Service("jsoupService")
public class JsoupService {
//....
}


inject other objects are normal , they jsoupService always NULL. Very puzzled.
------ Solution ---------------------------------------- ----
@ Resource
private JsoupService jsoupService; like that look .
JsoupService is not the case in this Service tag you have a problem

------ For reference only ---------------------------------- -----
@ Resource (name = "jsoupService") public void setJsoupService (JsoupService jsoupService) { this.jsoupService = jsoupService;}
landlord to test whether this method has been executed
------ For reference only ------------------------- --------------

tested , the output has a value.
------ For reference only -------------------------------------- -
service can not be injected into the service in
------ For reference only ---------------------------- -----------

I changed the @ Service @ Component ("jsoupService") is still not ah.
------ For reference only -------------------------------------- -

other injected into the service did not appear in this situation ah.
------ For reference only -------------------------------------- -
System.out.println (jsoupService)
view this object does not exist . If there is a problem to explain returns , check getsyllabus logic.

------ For reference only ---------------------------------- -----

output of these two places have a value , other places no value on it.


public JsoupService getJsoupService() {
                System.out.println(jsoupService);//这里输出有值
return jsoupService;
}

@Resource(name ="jsoupService")
public void setJsoupService(JsoupService jsoupService) {
                System.out.println(jsoupService);//这里输出有值
this.jsoupService = jsoupService;
}



------ For reference only ---------------------------------- -----
you directly call getJsoupService () method to see whether the correct execution
------ For reference only ----------------- ----------------------

output is a null value.
------ For reference only -------------------------------------- -
@ Resource
public void setJsoupService (JsoupService jsoupService) {this.jsoupService = jsoupService; try this way }
------ For reference only ----------------------------- ----------
check the configuration
label
------ For reference only ----------------------- ----------------
1, you have to look at the first choice , your every component is not already created, using junit to test it .
2, you put the following code simply rephrase .

@ Resource (name = "jsoupService")
public void setJsoupService (JsoupService jsoupService) {
System.out.println (jsoupService) ;/ / output are here value
this.jsoupService = jsoupService;
}
as:
@ Resource (name = "jsoupService")
private JsoupService jsoupService;
Do not set above plus annotated .
------ For reference only -------------------------------------- -

same. Useless .
------ For reference only -------------------------------------- -



<context:annotation-config/>
<context:component-scan base-package="cn.recx.wechat"/>

correct.


------ For reference only ---------------------------------- -----


when used are NULL. This situation does not appear before the ah. Another look at the pictures. Remote help me find
------ For reference only --------------------------------- ------
740202157 you add my QQ Well
------ For reference only ----------------------- ----------------

tried this again. Or not , or NULL.
------ For reference only -------------------------------------- -
in action in the new up . Problems caused

没有评论:

发表评论