招聘网有哪些网站比较好肇庆seo排名外包
2026/5/13 9:54:48 网站建设 项目流程
招聘网有哪些网站比较好,肇庆seo排名外包,企业网站系统源码,学会服务站建站方案Spring配置 别名 alias标签 !--别名#xff0c;如果添加了别名#xff0c;我们也可以使用别名获取到这个对象-- alias nameuser aliasbalbala/实例化容器的时候调用 User user (User) context.getBean(balbala);实际上…Spring配置别名alias标签!--别名如果添加了别名我们也可以使用别名获取到这个对象--aliasnameuseraliasbalbala/实例化容器的时候调用Useruser(User)context.getBean(balbala);实际上取别名不如用bean不推荐使用这种方式起别名Bean的配置idbean的唯一标识符也就是相当于我们new对象的一个变量名它也可以说是Spring容器的的idclass: bean 对象所对应的全限定名包名类名new的那个对象的类名name也是别名而且name更高级可以同时取多个别名空格隔开、逗号、分号bean iduser2classcom.cike3.pojo.User2nameuserT u2,u3;u4property namenamevaluecike_y//beanimport这个import一般用于团队开发使用它可以将多个配置文件导入合并为一个假设现在项目中有多个人开发这三个人负责不同的类开发不同的类需要注册的bean中我们可以利用import将所有人的beans.xml合并为一个总的张三李四王五applicationContext.xml正规的命名importresourcebeans.xml/importresourcebeans2.xml/使用的时候直接使用总的配置官方文档https://docs.spring.io/spring-framework/reference/core/beans/dependencies/factory-collaborators.html https://docs.spring.io/spring-framework/docs/5.2.0.RELEASE/spring-framework-reference/core.html#beans-constructor-injection依赖注入构造器注入前面 IoC创建对象的方式“set方式注入【重点】依赖注入本质是Set注入依赖bean对象的对象依赖于容器注入bean对象中的所有属性由容器来注入主要有以下注入普通值注入valuebeanidstudentclasscom.cike4.pojo.Student!--第一种普通值注入直接使用value--propertynamenamevaluecike_y//beanBean注入refbeanidaddressclasscom.cike4.pojo.Addresspropertynameaddressvalue广东//beanbeanidstudentclasscom.cike4.pojo.Student!--第二种Bean注入ref引用address容器id--propertynameaddressrefaddress//bean数组注入beanidstudentclasscom.cike4.pojo.Student!--数组注入--propertynamebooksarrayvalue十日终焉/valuevalue凡人修仙传/valuevalue夏日重现/value/array/property/beanList注入beanidstudentclasscom.cike4.pojo.Studentpropertynamehobbyslistvalue打游戏/valuevalue看电影/valuevalue爱躺平/value/list/property/beanMap注入beanidstudentclasscom.cike4.pojo.Student!--Map 注入--propertynamecardmapentrykey身份证value444444444444444444//map/property/beanSetbeanidstudentclasscom.cike4.pojo.Student!--Set--propertynamegamessetvalue和平精英/valuevalue原神/value/set/property/beannullbeanidstudentclasscom.cike4.pojo.Student!-- null value默认不写为null property namewife value/ --propertynamewifenull//property/beanPropertiesbeanidstudentclasscom.cike4.pojo.Student!--Properties--propertynameinfopropspropkey学号20230302222/proppropkey姓名cike_y/proppropkey性别男/proppropkeyusernameroot/proppropkeypassword123456/prop/props/property/bean【环境搭建】复杂类型publicclassAddress{privateStringaddress;publicStringgetAddress(){returnaddress;}publicvoidsetAddress(Stringaddress){this.addressaddress;}}真实测试对象publicclassStudent{// 引用类型privateStringname;privateAddressaddress;privateString[]books;privateListStringhobbys;privateMapString,Objectcard;privateSetStringgames;privateStringwife;privatePropertiesinfo;}完整的beans.xml?xml version1.0 encodingUTF-8?beansxmlnshttp://www.springframework.org/schema/beansxmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexsi:schemaLocationhttp://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsdbeanidaddressclasscom.cike4.pojo.Addresspropertynameaddressvalue广东//beanbeanidstudentclasscom.cike4.pojo.Student!--第一种普通值注入直接使用value--propertynamenamevaluecike_y/!--第二种Bean注入ref--propertynameaddressrefaddress/!--数组注入--propertynamebooksarrayvalue十日终焉/valuevalue凡人修仙传/valuevalue夏日重现/value/array/property!--List注入--propertynamehobbyslistvalue打游戏/valuevalue看电影/valuevalue爱躺平/value/list/property!--Map 注入--propertynamecardmapentrykey身份证value444444444444444444//map/property!--Set--propertynamegamessetvalue和平精英/valuevalue原神/value/set/property!-- null value默认不写为null property namewife value/ --propertynamewifenull//property!--Properties--propertynameinfopropspropkey学号20230302222/proppropkey姓名cike_y/proppropkey性别男/proppropkeyusernameroot/proppropkeypassword123456/prop/props/property/bean/beans测试类publicclasssprint_04_Test{Testpublicvoidtest(){ApplicationContextcontextnewClassPathXmlApplicationContext(beans.xml);Studentstudent(Student)context.getBean(student);System.out.println(student.toString());/* * Student{namecike_y, * addressAddress{address广东}, * books[十日终焉, 凡人修仙传, 夏日重现], * hobbys[打游戏, 看电影, 爱躺平], * card{身份证444444444444444444}, * games[和平精英, 原神], * wifenull, * info{ * 学号20230302222, * 性别男, * password123456, * 姓名cike_y, * usernameroot * } * } */}}官方文档https://docs.spring.io/spring-framework/docs/5.2.0.RELEASE/spring-framework-reference/core.html#beans-collection-elements https://docs.spring.io/spring-framework/reference/core/beans/dependencies/factory-properties-detailed.html扩展注入注意p命名空间和c命名空间的使用需要导入xml约束xmlns:phttp://www.springframework.org/schema/pxmlns:chttp://www.springframework.org/schema/cp命名空间 相当于set)要用它一定要先导入官方文档中的p命名空间xmlns:phttp://www.springframework.org/schema/p它对应着set注入的一些方法普通值注入引用ref对象!--p命名空间注入可以直接注入属性的值property--beaniduserclasscom.cike4.pojo.Userp:namecike_yp:age20/!--相当于 bean iduser classcom.cike4.pojo.User property namename valuecike_y/ property nameage value20/ /bean --也可以引用其他的Bean对象userbeans.xml中?xml version1.0 encodingUTF-8?beansxmlnshttp://www.springframework.org/schema/beansxmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexmlns:phttp://www.springframework.org/schema/pxsi:schemaLocationhttp://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd!--p命名空间注入可以直接注入属性的值property--beaniduserclasscom.cike4.pojo.Userp:namecike_yp:age20/!--相当于 bean iduser classcom.cike4.pojo.User property namename valuecike_y/ property nameage value20/ /bean --/beansJavaBean 的User类publicclassUser{privateStringname;privateintage;publicStringgetName(){returnname;}publicvoidsetName(Stringname){this.namename;}publicintgetAge(){returnage;}publicvoidsetAge(intage){this.ageage;}OverridepublicStringtoString(){returnUser{namename\, ageage};}}测试方法中实例化对象Testpublicvoidtest2(){ApplicationContextcontextnewClassPathXmlApplicationContext(userbeans.xml);// 这里申明了类型就不需要强壮类型 User 类了Userusercontext.getBean(user,User.class);System.out.println(user.toString());}c命名空间相当于构造器注入要先导入c命名空间xmlns:chttp://www.springframework.org/schema/cuserbean.xml 中!--c命名空间注入可以通过构造器注入construct-args--beaniduser2classcom.cike4.pojo.Userc:nameuser2c:age20/!--相当于 bean iduser2 classcom.cike4.pojo.User constructor-arg namename valuecike_y/ constructor-arg nameage value20/ /bean --User类添加构造器方法publicUser(){}publicUser(Stringname,intage){this.namename;this.ageage;}测试方法Testpublicvoidtest2(){ApplicationContextcontextnewClassPathXmlApplicationContext(userbeans.xml);// 这里申明了类型就不需要强壮类型 User 类了Userusercontext.getBean(user2,User.class);System.out.println(user.toString());}官方解释官方文档https://docs.spring.io/spring-framework/docs/5.2.0.RELEASE/spring-framework-reference/core.html#beans-p-namespace https://docs.spring.io/spring-framework/reference/core/beans/dependencies/factory-properties-detailed.html#beans-p-namespace

需要专业的网站建设服务?

联系我们获取免费的网站建设咨询和方案报价,让我们帮助您实现业务目标

立即咨询