2013年9月11日星期三

About spring bean injected a problem

There are five methods, namely all queries by id query, add, delete, modify, query them in the use of this method by id when checking the output object being injected result null, but use other methods when all four can be successful , check the output result is injected into a target object , obviously into a success, but when using the method becomes a null why ? Find great God to answer

configuration file:




service:

public class GoodsService{
private GoodsDAO goodsdao;

public GoodsDAO getGoodsdao() {
       return goodsdao;
}

public void setGoodsdao(GoodsDAO goodsdao) {
       this.goodsdao = goodsdao;
}

public GoodsSC queGoodsById(int id){
       return goodsdao.queryByid(id);
}



------ Solution ------------------------------------- -------
database does not exist will not be recorded ?
------ Solution ---------------------------------------- ----
put that sf of the bean also posted out
------ Solution ---------------------- ----------------------
the call GoodsService place stickers.
theoretically
This node should be added to an attribute prototype = "singleton"
------ For reference only ---------------------- -----------------

no, I start with the database query out all the data, and then in the form of a hyperlink id query by calling this method , it is impossible to have a database problem does not exist
------ For reference only ----------------------------- ----------
it is not very clear. Landlord may then check the configuration file to see if there is no leakage of injected class ( but not injected , it should be throwing NullPointerException ...).
------ For reference only -------------------------------------- -

bean configuration files that I have posted, but it really is a null pointer exception reported after examination found no injection
------ For reference only ---- -----------------------------------
There is no need GETGOODSDAO this method
--- --- For reference only ---------------------------------------

public class GoodsService{
    private GoodsDAO goodsdao;
 
    public GoodsSC queGoodsById(int id){
          return goodsdao.queryByid(id);
     }

         
      public void setGoodsdao(GoodsDAO goodsdao) {
               this.goodsdao = goodsdao;
       }
 



------ For reference only ------------------------------------- -
you inject and action in the set to be the same, do not know the reason
------ For reference only ----------------- ----------------------

should not be the problem, after removing or not
------ For reference only ---------------------------------------

I checked yes consistent, and I for one another attribute name is still the same not
------ For reference only ----------------------- ----------------
and your service of bean
------ For reference only ------------- --------------------------

sf of bean:










service of bean:



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




This is mislabeled , or which have less xml
?
------ For reference only ---------------- -----------------------

amount posted the wrong





com / csms / po / EntryDetailPO.hbm.xml
com / csms / po / GoodsPO.hbm.xml
com / csms / po / GoodsSC.hbm.xml
com / csms / po / OutDetailPO.hbm.xml
com / csms / po / StockPO.hbm.xml
com / csms / po / StorageEntryPO.hbm.xml
com / csms / po / StorageOutPO.hbm.xml
com / csms / po / StoragePO.hbm.xml
com / csms / po / UserPO.hbm.xml





org.hibernate.dialect.MySQLDialect < / prop>



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

should be scope = "singleton" , huh but not that by default singleton do ? But once you went to check reminder service parts and found an error in the action method turned out to be inside a gs re new object
------ For reference only ---------------------------------------

problem has been found , the original method in action inside a gs re new object caused , thank you for your answer

没有评论:

发表评论