File tree 9 files changed +137
-1
lines changed
src/main/java/com/springcore1/constructorInjectionWithoutUsingCschema
META-INF/maven/com.springcore/springcore
com/springcore1/constructorInjectionWithoutUsingCschema
9 files changed +137
-1
lines changed Original file line number Diff line number Diff line change
1
+ package com .springcore1 .constructorInjectionWithoutUsingCschema ;
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/constructorInjectionWithoutUsingCschema/ciconfig.xml" );
10
+ PersonDetail objDetail =(PersonDetail ) context .getBean ("objPerson" );
11
+ System .out .println (objDetail );
12
+ }
13
+ }
Original file line number Diff line number Diff line change
1
+ package com .springcore1 .constructorInjectionWithoutUsingCschema ;
2
+
3
+ public class Car {
4
+ String name ;
5
+ public Car (String name ) {
6
+ super ();
7
+ this .name =name ;
8
+ }
9
+ @ Override
10
+ public String toString () {
11
+ return this .name ;
12
+ }
13
+
14
+
15
+ }
Original file line number Diff line number Diff line change
1
+ package com .springcore1 .constructorInjectionWithoutUsingCschema ;
2
+
3
+ import java .awt .CardLayout ;
4
+ import java .security .Signature ;
5
+ import java .util .List ;
6
+
7
+ public class PersonDetail {
8
+
9
+ private String name ;
10
+ private int age ;
11
+ // private List<String> books;
12
+ private Car car ;
13
+ public PersonDetail (String name , int age , Car car ) {
14
+ super ();
15
+ this .name = name ;
16
+ this .age = age ;
17
+ // this.books = books;
18
+ this .car = car ;
19
+ }
20
+ @ Override
21
+ public String toString () {
22
+ return "PersonDetail == > [name=" + name + ", age=" + age + ", carName=" + car + "]" ;
23
+ }
24
+
25
+
26
+
27
+
28
+ }
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
+ <bean class =" com.springcore1.constructorInjectionWithoutUsingCschema.Car" name =" refCar1" >
16
+ <constructor-arg type =" String" value =" thar" />
17
+ </bean >
18
+
19
+
20
+ <bean class =" com.springcore1.constructorInjectionWithoutUsingCschema.PersonDetail" name =" objPerson" >
21
+ <constructor-arg value =" Shikhar" type =" String" />
22
+ <constructor-arg value =" 25" type =" int" />
23
+ <constructor-arg ref =" refCar1" />
24
+
25
+
26
+
27
+
28
+
29
+
30
+
31
+
32
+
33
+
34
+ </bean >
35
+
36
+
37
+
38
+
39
+
40
+ </beans >
Original file line number Diff line number Diff line change 1
1
# Generated by Maven Integration for Eclipse
2
- # Mon Aug 12 17:04:52 IST 2024
2
+ # Mon Aug 12 17:31:53 IST 2024
3
3
artifactId =springcore
4
4
groupId =com.springcore
5
5
m2e.projectLocation =/Volumes/project/LearningSpring/springcore1
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
+ <bean class =" com.springcore1.constructorInjectionWithoutUsingCschema.Car" name =" refCar1" >
16
+ <constructor-arg type =" String" value =" thar" />
17
+ </bean >
18
+
19
+
20
+ <bean class =" com.springcore1.constructorInjectionWithoutUsingCschema.PersonDetail" name =" objPerson" >
21
+ <constructor-arg value =" Shikhar" type =" String" />
22
+ <constructor-arg value =" 25" type =" int" />
23
+ <constructor-arg ref =" refCar1" />
24
+
25
+
26
+
27
+
28
+
29
+
30
+
31
+
32
+
33
+
34
+ </bean >
35
+
36
+
37
+
38
+
39
+
40
+ </beans >
You can’t perform that action at this time.
0 commit comments