Notice
Recent Posts
Recent Comments
Link
반응형
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- 힘들다
- 프랑스어
- 세일즈포스
- 윈도우 #크롬탭 #크롭탭복사 #크롬탭복제 #크롬사용법 #크롬꿀팁 #업무꿀팁 #일상꿀팁
- 힘들어도
- 국비과정
- 프랑스어배우는이유
- SF
- 음식사진없음
- MarketingCloud
- JPOP
- 더이상의 자세한 설명은 생략한다
- 프랑스어기초
- 셀포
- 마무리구원투수내동생땡큐
- 제목은음식인데
- 생산성 #24시간알차게 #올해의시간트레이닝 #셀프코치
- 다먹어치움
- 프랑스어단어
- 마케팅클라우드
Archives
- Today
- Total
뚜벅이
왕초보가 스프링 sts 4 에서 bean 갖고놀기 본문
반응형
폰 관련 bean들 담겨있는 xml파일
pp.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean name="ps" class="java.util.ArrayList">
<constructor-arg>
<list>
<bean class="di.model.Ph">
<property name="name" value="폰넘버1" />
<property name="btr" ref="btr1" />
<property name="cmr" ref="cmr1" />
<property name="sz" ref="sz1" />
</bean>
<bean class="di.model.Ph">
<property name="name" value="갤갤" />
<property name="btr" ref="btr2" />
<property name="cmr" ref="cmr2" />
<property name="sz" ref="sz2" />
</bean>
<bean class="di.model.Ph">
<property name="name">
<value>갤럭시</value>
</property>
<property name="btr" ref="btr3" />
<property name="cmr" ref="cmr3" />
<property name="sz" ref="sz3" />
</bean>
</list>
</constructor-arg>
</bean>
<bean name="ppp1" class="di.model.Ph">
<property name="name" value="폰넘버1" />
<property name="btr" ref="btr1" />
<property name="cmr" ref="cmr1" />
<property name="sz" ref="sz1" />
</bean>
<bean name="ppp2" class="di.model.Ph">
<property name="name" value="갤갤" />
<property name="btr" ref="btr2" />
<property name="cmr" ref="cmr2" />
<property name="sz" ref="sz2" />
</bean>
<bean name="ppp3" class="di.model.Ph">
<property name="name">
<value>갤럭시</value>
</property>
<property name="btr" ref="btr3" />
<property name="cmr" ref="cmr3" />
<property name="sz" ref="sz3" />
</bean>
<bean name="btr1" class="di.model.Btr">
<property name="yong">
<value>2000</value>
</property>
<property name="scale" value="중형" />
</bean>
<bean name="btr2" class="di.model.Btr">
<property name="yong">
<value>6000</value>
</property>
<property name="scale" value="소형" />
</bean>
<bean name="btr3" class="di.model.Btr">
<property name="yong">
<value>12000</value>
</property>
<property name="scale" value="대형" />
</bean>
<bean name="cmr1" class="di.model.Cmr">
<property name="type" value="전문가용"></property>
<property name="pixel" value="4500"></property>
</bean>
<bean name="cmr2" class="di.model.Cmr">
<property name="type" value="일반용"></property>
<property name="pixel" value="1500"></property>
</bean>
<bean name="cmr3" class="di.model.Cmr">
<property name="type" value="천문용"></property>
<property name="pixel" value="9500"></property>
</bean>
<bean name="sz1" class="di.model.Sz">
<constructor-arg name="width" value="600" />
<constructor-arg name="height" value="900" />
</bean>
<bean name="sz2" class="di.model.Sz">
<constructor-arg name="width" value="1600" />
<constructor-arg name="height" value="1900" />
</bean>
<bean name="sz3" class="di.model.Sz">
<constructor-arg name="width" value="2600" />
<constructor-arg name="height" value="2900" />
</bean>
</beans>
|
dddd
ddd폰 정의 클래스
+
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
package di.model;
import java.util.Arrays;
public class Ph {
String name;
Btr btr;
Cmr cmr;
Sz sz;
@Override
public String toString() {
return "폰:: [name=" + name + ", btr=" + btr + ", cmr=" + cmr + ", sz=" + sz + "]\n";
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Btr getBtr() {
return btr;
}
public void setBtr(Btr btr) {
this.btr = btr;
}
public Cmr getCmr() {
return cmr;
}
public void setCmr(Cmr cmr) {
this.cmr = cmr;
}
public Sz getSz() {
return sz;
}
public void setSz(Sz sz) {
this.sz = sz;
}
}
class Btr {
String yong, scale;
public String getYong() {
return yong;
}
public void setYong(String yong) {
this.yong = yong + " mAh";
}
public String getScale() {
return scale;
}
public void setScale(String scale) {
this.scale = scale + " 인치";
}
@Override
public String toString() {
return "Btr [yong=" + yong + ", scale=" + scale + "]";
}
}
class Cmr {
String type;
String pixel;
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getPixel() {
return pixel;
}
public void setPixel(String pixel) {
this.pixel = pixel + " 만 화소";
}
@Override
public String toString() {
return "Cmr [type=" + type + ", pixel=" + pixel + "]";
}
}
class Sz {
int width, height;
private Sz(int width, int height) {
this.width = width;
this.height = height;
}
@Override
public String toString() {
return "Sz [width=" + width + ", height=" + height + "]";
}
}
|
cs |
폰 출력 실행 main클래스
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
package di.main;
import java.util.ArrayList;
import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import di.model.Ph;
public class PoMain {
static AbstractApplicationContext context = new ClassPathXmlApplicationContext("di_xml/pp.xml");
public static void main(String[] args) {
Ph p1 = (Ph) context.getBean("ppp1", "di.model.Ph");
p1 = context.getBean("ppp1", Ph.class);
System.out.println("폰 넘버원" + p1);
ArrayList<Ph> arr = new ArrayList<>();
arr = context.getBean("ps", ArrayList.class);
System.out.println(arr);
}
}
|
cs |
ds
느낀 점
bean 에서 > string으로 받는다 파싱을 해주어야 하는걸까? "26" 숫자만 넣으면 되는것이 있긴했다.
한마디로 어떤 클래스의 변수가. String 형인데. int 로 setter 를 만들면.
spring은 헷갈려하는 것 같다.
예를들어서
public void setPixel(String pixel) {
this.pixel = pixel + " 만 화소";
}
이거를
public void setPixel( int pixel) {
this.pixel = pixel + " 만 화소";
}
로 하고 싶었는데.
스프링은 일단 pixel 이 뭔 자료형인지를 따진 뒤에 .
setter 를 읽는 것 같다. 그래서오류를 밷는데
" 얌마 너 pixel 스트링으로 선언 했잖아. 근데 왜 세터는 int로 세터 돌아가게 하느냐 ??
라고 하면서 거부한다. "
bean이 다 해줄것 같지만 내부적으로 자기만의 엄격한 규칙,공식, 형식, 규율 이 있음을 느낄 수 있었다.
반응형
'국비과정 JAVA공부' 카테고리의 다른 글
마이바티스를 위한 xml 파일 편집좀더 편하게 하기 (0) | 2021.05.14 |
---|---|
0324 배운것들 (0) | 2021.03.24 |
JAVA -keylistener 의 아들 keyadapter// 숫자이외 입력 씹어버리기. (0) | 2021.03.19 |
0318 또 로젝트.. (0) | 2021.03.18 |
0315 이 프로젝트 기간은. 응용을 극한으로 끌어내야 하는 시간인데.. (0) | 2021.03.15 |