Encountered an error in learning Spring: note @resources: The annotation @Resources is disallowed for
Later came in the knowledge of Java netizens to solve.
The original code is this:
1 Packagecom.show.biz;2 3 Importjavax.annotation.Resources;4 5 ImportCom.show.biz.UserBiz;6 ImportCom.show.dao.UserDAO;7 8 Public classUserbizimplbyannotationofresourceImplementsuserbiz {9 Ten //Annotate annotations on Userdao One@Resources (name= "Userdao")//or use @resources directly . A Userdao Userdao; - - //Annotate annotations on the set method of the Userdao the@Resources (name= "Userdao") - Public voidSetuserdao (Userdao Userdao) { - This. Userdao =Userdao; - } + - Public BooleanLogin (string username, string password) { + A returnuserdao.login (username, password); at } - -}
Netizens hint: @Resources changed into a @resource, the result really became. The modified code is as follows:
Packagecom.show.biz;ImportJavax.annotation.Resource;Importjavax.annotation.Resources;ImportCom.show.biz.UserBiz;ImportCom.show.dao.UserDAO; Public classUserbizimplbyannotationofresourceImplementsuserbiz {//Annotate annotations on Userdao@Resource (name= "Userdao")//or use @resources directly .Userdao Userdao; //Annotate annotations on the set method of the Userdao@Resource (name= "Userdao") Public voidSetuserdao (Userdao Userdao) { This. Userdao =Userdao; } Public BooleanLogin (string username, string password) {returnuserdao.login (username, password); }}
One error in spring: Using the Resources times to be wrong (the annotation @Resources is disallowed)