一.属性自动装配

 首先,准备三个类,分别是User,Cat,Dog。其中User属性拥有Cat和Dog对象。

 1 package com.hdu.autowire;
 2 
 3 public class User {
 4     private Cat cat;
 5     private Dog dog;
 6     private String str;
 7     
 8     public Cat getCat() {
 9         return cat;
10     }
11     public void setCat(Cat cat) {
12         this.cat = cat;
13     }
14     public Dog getDog() {
15         return dog;
16     }
17     public void setDog(Dog dog) {
18         this.dog = dog;
19     }
20     public String getStr() {
21         return str;
22     }
23     public void setStr(String str) {
24         this.str = str;
25     }
26 }
Class User

相关文章:

  • 2021-11-03
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-02-12
  • 2021-10-28
  • 2022-02-14
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案