File tree 3 files changed +77
-0
lines changed
src/main/java/com/springcore1/constructorInjectionWithoutUsingCschemaAbiguity
3 files changed +77
-0
lines changed Original file line number Diff line number Diff line change
1
+ package com .springcore1 .constructorInjectionWithoutUsingCschemaAbiguity ;
2
+
3
+ public class Addition {
4
+ private int a ;
5
+ private int b ;
6
+ public Addition (int a , int b ) {
7
+ super ();
8
+ this .a = a ;
9
+ this .b = b ;
10
+ System .out .println ("a + b = int , int " +(this .a +this .b ));
11
+ }
12
+ public Addition ( double a , double b ) {
13
+ super ();
14
+ this .a = (int ) a ;
15
+ this .b = (int )b ;
16
+ System .out .println ("a + b = D, D " +(this .a +this .b ));
17
+ }
18
+ public Addition ( String a , String b ) {
19
+ super ();
20
+ this .a = Integer .parseInt (a );
21
+ this .b = Integer .parseInt (b );
22
+ System .out .println ("a + b = Str, Str " +(this .a +this .b ));
23
+ }
24
+
25
+
26
+
27
+ }
Original file line number Diff line number Diff line change
1
+ package com .springcore1 .constructorInjectionWithoutUsingCschemaAbiguity ;
2
+
3
+ import org .springframework .context .ApplicationContext ;
4
+ import org .springframework .context .support .ClassPathXmlApplicationContext ;
5
+
6
+ public class App {
7
+
8
+ public static void main (String [] args ) {
9
+ ApplicationContext context = new ClassPathXmlApplicationContext ("com/springcore1/constructorInjectionWithoutUsingCschemaAbiguity/ciconfig.xml" );
10
+ Addition addition =(Addition ) context .getBean ("addition" );
11
+ System .out .println (addition );
12
+ }
13
+ }
Original file line number Diff line number Diff line change
1
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2
+ <beans xmlns =" http://www.springframework.org/schema/beans"
3
+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
4
+ xmlns : context =" http://www.springframework.org/schema/context"
5
+ xmlns : p =" http://www.springframework.org/schema/p"
6
+ xsi : schemaLocation =" http://www.springframework.org/schema/beans
7
+ http://www.springframework.org/schema/beans/spring-beans.xsd
8
+ http://www.springframework.org/schema/context
9
+ http://www.springframework.org/schema/context/spring-context.xsd" >
10
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+ <bean class =" com.springcore1.constructorInjectionWithoutUsingCschemaAbiguity.Addition" name =" addition" >
19
+ <constructor-arg value =" 25" />
20
+ <constructor-arg value =" 25" />
21
+
22
+
23
+
24
+
25
+
26
+
27
+
28
+
29
+
30
+
31
+ </bean >
32
+
33
+
34
+
35
+
36
+
37
+ </beans >
You can’t perform that action at this time.
0 commit comments