Skip to content

Commit 911f2c1

Browse files
committed
extrA ways of ref injection
1 parent 545b42d commit 911f2c1

File tree

9 files changed

+134
-4
lines changed

9 files changed

+134
-4
lines changed

Diff for: src/main/java/com/springcore1/refenceInjection/App.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ public class App {
77
public static void main(String[] args) {
88

99

10-
ApplicationContext context= new ClassPathXmlApplicationContext("com/springcore1/refenceInjection/refconfig.xml");
10+
ApplicationContext context= new ClassPathXmlApplicationContext("com/springcore1/refenceInjection/refconfigUsingRefAttribute.xml");
1111
A objA =(A)context.getBean("aref");
1212
System.out.println(objA);
1313
System.out.println("------------------------");

Diff for: src/main/java/com/springcore1/refenceInjection/refconfig.xml

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
</bean> -->
2424
<bean class="com.springcore1.refenceInjection.A" name="aref">
2525
<property name="x" value="111" />
26-
<property name="objB"> <ref bean="bref"/>
26+
<property name="objB">
27+
<ref bean="bref"/>
2728
</property>
2829
</bean>
2930

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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+
<bean class="com.springcore1.refenceInjection.B" name="bref" p:y="000" >
14+
15+
</bean>
16+
17+
18+
<!-- <bean class="com.springcore1.refenceInjection.A" name="aref">
19+
<property name="x" value="111" />
20+
<property name="ob">
21+
<ref bean="bref"/>
22+
</property>
23+
</bean> -->
24+
<bean class="com.springcore1.refenceInjection.A" name="aref" p:x="559" p:objB-ref="bref">
25+
26+
</bean>
27+
28+
29+
30+
31+
</beans>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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+
<bean class="com.springcore1.refenceInjection.B" name="bref" >
14+
<property name="y" value="2222" />
15+
</bean>
16+
17+
18+
<!-- <bean class="com.springcore1.refenceInjection.A" name="aref">
19+
<property name="x" value="111" />
20+
<property name="ob">
21+
<ref bean="bref"/>
22+
</property>
23+
</bean> -->
24+
<bean class="com.springcore1.refenceInjection.A" name="aref">
25+
<property name="x" value="111" />
26+
<property name="objB" ref="bref" />
27+
28+
</bean>
29+
30+
31+
32+
33+
</beans>

Diff for: target/classes/META-INF/maven/com.springcore/springcore/pom.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#Generated by Maven Integration for Eclipse
2-
#Mon Aug 12 03:13:41 IST 2024
2+
#Mon Aug 12 04:03:11 IST 2024
33
artifactId=springcore
44
groupId=com.springcore
55
m2e.projectLocation=/Volumes/project/LearningSpring/springcore1
17 Bytes
Binary file not shown.

Diff for: target/classes/com/springcore1/refenceInjection/refconfig.xml

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
</bean> -->
2424
<bean class="com.springcore1.refenceInjection.A" name="aref">
2525
<property name="x" value="111" />
26-
<property name="objB"> <ref bean="bref"/>
26+
<property name="objB">
27+
<ref bean="bref"/>
2728
</property>
2829
</bean>
2930

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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+
<bean class="com.springcore1.refenceInjection.B" name="bref" p:y="000" >
14+
15+
</bean>
16+
17+
18+
<!-- <bean class="com.springcore1.refenceInjection.A" name="aref">
19+
<property name="x" value="111" />
20+
<property name="ob">
21+
<ref bean="bref"/>
22+
</property>
23+
</bean> -->
24+
<bean class="com.springcore1.refenceInjection.A" name="aref" p:x="559" p:objB-ref="bref">
25+
26+
</bean>
27+
28+
29+
30+
31+
</beans>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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+
<bean class="com.springcore1.refenceInjection.B" name="bref" >
14+
<property name="y" value="2222" />
15+
</bean>
16+
17+
18+
<!-- <bean class="com.springcore1.refenceInjection.A" name="aref">
19+
<property name="x" value="111" />
20+
<property name="ob">
21+
<ref bean="bref"/>
22+
</property>
23+
</bean> -->
24+
<bean class="com.springcore1.refenceInjection.A" name="aref">
25+
<property name="x" value="111" />
26+
<property name="objB" ref="bref" />
27+
28+
</bean>
29+
30+
31+
32+
33+
</beans>

0 commit comments

Comments
 (0)