Spring实例--ICHDBank

第一步 建立工程

netbeans-->java web -->web application

第二步 创建Java类

 

 在Java类中写入变量元素并且构建封装字段

  1 /*
  2  * To change this license header, choose License Headers in Project Properties.
  3  * To change this template file, choose Tools | Templates
  4  * and open the template in the editor.
  5  */
  6 package ICHDApp;
  7 
  8 /**
  9  *
 10  * @author Administrator
 11  */
 12 public class Customer {
 13    //create firstname ;middleName;  lastname ;dateofbirth;monthofbrith;yearofbirth;
 14     //mothername;emailname;gender;maritalstatus;housena;
 15     //houseno ;streetname;state;city;pincode;phone;username;password;
 16     private String accountName;
 17     private String firstName;
 18     private String middleName;
 19     private String lastName;
 20     private String dataOfBirth;    private String monoOfBirth;
 21     private String yearOfBirth;
 22     private String motherName;
 23     private String emailName;
 24     private String gender;
 25     private String maritalstatus;
 26     private String housename;
 27     private String houseNo;
 28     
 29     private String streetName;
 30     private String state;
 31     private String city;
 32     private String pincode;
 33     
 34     private String phone;
 35     private String username;
 36     private String password;
 37     public Customer(){
 38     
 39     }
 40 
 41     /**
 42      * @return the accountName
 43      */
 44     public String getAccountName() {
 45         return accountName;
 46     }
 47 
 48     /**
 49      * @param accountName the accountName to set
 50      */
 51     public void setAccountName(String accountName) {
 52         this.accountName = accountName;
 53     }
 54 
 55     /**
 56      * @return the firstName
 57      */
 58     public String getFirstName() {
 59         return firstName;
 60     }
 61 
 62     /**
 63      * @param firstName the firstName to set
 64      */
 65     public void setFirstName(String firstName) {
 66         this.firstName = firstName;
 67     }
 68 
 69     /**
 70      * @return the middleName
 71      */
 72     public String getMiddleName() {
 73         return middleName;
 74     }
 75 
 76     /**
 77      * @param middleName the middleName to set
 78      */
 79     public void setMiddleName(String middleName) {
 80         this.middleName = middleName;
 81     }
 82 
 83     /**
 84      * @return the lastName
 85      */
 86     public String getLastName() {
 87         return lastName;
 88     }
 89 
 90     /**
 91      * @param lastName the lastName to set
 92      */
 93     public void setLastName(String lastName) {
 94         this.lastName = lastName;
 95     }
 96 
 97     /**
 98      * @return the dataOfBirth
 99      */
100     public String getDataOfBirth() {
101         return dataOfBirth;
102     }
103 
104     /**
105      * @param dataOfBirth the dataOfBirth to set
106      */
107     public void setDataOfBirth(String dataOfBirth) {
108         this.dataOfBirth = dataOfBirth;
109     }
110 
111     /**
112      * @return the monoOfBirth
113      */
114     public String getMonoOfBirth() {
115         return monoOfBirth;
116     }
117 
118     /**
119      * @param monoOfBirth the monoOfBirth to set
120      */
121     public void setMonoOfBirth(String monoOfBirth) {
122         this.monoOfBirth = monoOfBirth;
123     }
124 
125     /**
126      * @return the yearOfBirth
127      */
128     public String getYearOfBirth() {
129         return yearOfBirth;
130     }
131 
132     /**
133      * @param yearOfBirth the yearOfBirth to set
134      */
135     public void setYearOfBirth(String yearOfBirth) {
136         this.yearOfBirth = yearOfBirth;
137     }
138 
139     /**
140      * @return the motherName
141      */
142     public String getMotherName() {
143         return motherName;
144     }
145 
146     /**
147      * @param motherName the motherName to set
148      */
149     public void setMotherName(String motherName) {
150         this.motherName = motherName;
151     }
152 
153     /**
154      * @return the emailName
155      */
156     public String getEmailName() {
157         return emailName;
158     }
159 
160     /**
161      * @param emailName the emailName to set
162      */
163     public void setEmailName(String emailName) {
164         this.emailName = emailName;
165     }
166 
167     /**
168      * @return the gender
169      */
170     public String getGender() {
171         return gender;
172     }
173 
174     /**
175      * @param gender the gender to set
176      */
177     public void setGender(String gender) {
178         this.gender = gender;
179     }
180 
181     /**
182      * @return the maritalstatus
183      */
184     public String getMaritalstatus() {
185         return maritalstatus;
186     }
187 
188     /**
189      * @param maritalstatus the maritalstatus to set
190      */
191     public void setMaritalstatus(String maritalstatus) {
192         this.maritalstatus = maritalstatus;
193     }
194 
195     /**
196      * @return the housename
197      */
198     public String getHousename() {
199         return housename;
200     }
201 
202     /**
203      * @param housename the housename to set
204      */
205     public void setHousename(String housename) {
206         this.housename = housename;
207     }
208 
209     /**
210      * @return the houseNo
211      */
212     public String getHouseNo() {
213         return houseNo;
214     }
215 
216     /**
217      * @param houseNo the houseNo to set
218      */
219     public void setHouseNo(String houseNo) {
220         this.houseNo = houseNo;
221     }
222 
223     /**
224      * @return the streetName
225      */
226     public String getStreetName() {
227         return streetName;
228     }
229 
230     /**
231      * @param streetName the streetName to set
232      */
233     public void setStreetName(String streetName) {
234         this.streetName = streetName;
235     }
236 
237     /**
238      * @return the state
239      */
240     public String getState() {
241         return state;
242     }
243 
244     /**
245      * @param state the state to set
246      */
247     public void setState(String state) {
248         this.state = state;
249     }
250 
251     /**
252      * @return the city
253      */
254     public String getCity() {
255         return city;
256     }
257 
258     /**
259      * @param city the city to set
260      */
261     public void setCity(String city) {
262         this.city = city;
263     }
264 
265     /**
266      * @return the pincode
267      */
268     public String getPincode() {
269         return pincode;
270     }
271 
272     /**
273      * @param pincode the pincode to set
274      */
275     public void setPincode(String pincode) {
276         this.pincode = pincode;
277     }
278 
279     /**
280      * @return the phone
281      */
282     public String getPhone() {
283         return phone;
284     }
285 
286     /**
287      * @param phone the phone to set
288      */
289     public void setPhone(String phone) {
290         this.phone = phone;
291     }
292 
293     /**
294      * @return the username
295      */
296     public String getUsername() {
297         return username;
298     }
299 
300     /**
301      * @param username the username to set
302      */
303     public void setUsername(String username) {
304         this.username = username;
305     }
306 
307     /**
308      * @return the password
309      */
310     public String getPassword() {
311         return password;
312     }
313 
314     /**
315      * @param password the password to set
316      */
317     public void setPassword(String password) {
318         this.password = password;
319     }
320 }
Customer
 1 /*
 2  * To change this license header, choose License Headers in Project Properties.
 3  * To change this template file, choose Tools | Templates
 4  * and open the template in the editor.
 5  */
 6 package ICHDApp;
 7 
 8 /**
 9  *
10  * @author Administrator
11  */
12 public class Account {
13     //create accountnumber; accountcreationdate;balance;accounttype
14     private String accountNumber;
15     private String accountCreationDate;
16     private String balance;
17     private String accountType;
18     public Account(){    
19     }
20     public Account(String accountNumber,String accountCreationDate,String balance,String accountType){
21         this.accountNumber=accountNumber;
22         this.accountType=accountType;
23         this.balance=balance;
24         this.accountCreationDate=accountCreationDate;
25         
26     }
27 
28     /**
29      * @return the accountNumber
30      */
31     public String getAccountNumber() {
32         return accountNumber;
33     }
34 
35     /**
36      * @param accountNumber the accountNumber to set
37      */
38     public void setAccountNumber(String accountNumber) {
39         this.accountNumber = accountNumber;
40     }
41 
42     /**
43      * @return the accountCreationDate
44      */
45     public String getAccountCreationDate() {
46         return accountCreationDate;
47     }
48 
49     /**
50      * @param accountCreationDate the accountCreationDate to set
51      */
52     public void setAccountCreationDate(String accountCreationDate) {
53         this.accountCreationDate = accountCreationDate;
54     }
55 
56     /**
57      * @return the balance
58      */
59     public String getBalance() {
60         return balance;
61     }
62 
63     /**
64      * @param balance the balance to set
65      */
66     public void setBalance(String balance) {
67         this.balance = balance;
68     }
69 
70     /**
71      * @return the accountType
72      */
73     public String getAccountType() {
74         return accountType;
75     }
76 
77     /**
78      * @param accountType the accountType to set
79      */
80     public void setAccountType(String accountType) {
81         this.accountType = accountType;
82     }
83     
84 }
Account
 1 /*
 2  * To change this license header, choose License Headers in Project Properties.
 3  * To change this template file, choose Tools | Templates
 4  * and open the template in the editor.
 5  */
 6 package ICHDApp;
 7 
 8 /**
 9  *
10  * @author Administrator
11  */
12 public class FundTransfer {
13     private double amount;
14     public FundTransfer(){}
15     public FundTransfer(double amount){
16         this.amount=amount;
17     }
18 
19     /**
20      * @return the amount
21      */
22     public double getAmount() {
23         return amount;
24     }
25 
26     /**
27      * @param amount the amount to set
28      */
29     public void setAmount(double amount) {
30         this.amount = amount;
31     }
32 }
FundTransfer

第三步 创建testBeansWiring.java 主函数

创建主类 引入ApplicationContext

getbeans

 1 /*
 2  * To change this license header, choose License Headers in Project Properties.
 3  * To change this template file, choose Tools | Templates
 4  * and open the template in the editor.
 5  */
 6 package ICHDApp;
 7 
 8 import org.springframework.context.ApplicationContext;
 9 import org.springframework.context.support.ClassPathXmlApplicationContext;
10 
11 /**
12  *
13  * @author Administrator
14  */
15 public class TestBeanWriting {
16     public static void main(String s[]){
17         //创建springfactory容器
18         ApplicationContext ac=new ClassPathXmlApplicationContext("ICHDApp/Spring-Config.xml");
19         Customer cust =(Customer)ac.getBean("CustomerBean");
20         System.out.println("The Values are: ");
21         System.out.println("cust.getFirstName");
22         System.out.println("cust.getMiddleName");
23         System.out.println("cust.getLastName");
24     }
25 }
TestBeanWriting

 

转载于:https://www.cnblogs.com/Catherinezhilin/p/10579792.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值