Skip to content

Commit 343a743

Browse files
author
eugenp
committed
bean work
1 parent 94f9a60 commit 343a743

File tree

7 files changed

+22
-13
lines changed

7 files changed

+22
-13
lines changed

spring-all/src/main/java/org/baeldung/spring/config/PersistenceConfig.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import org.springframework.beans.factory.annotation.Autowired;
88
import org.springframework.context.annotation.Bean;
99
import org.springframework.context.annotation.ComponentScan;
10-
import org.springframework.context.annotation.Configuration;
1110
import org.springframework.context.annotation.PropertySource;
1211
import org.springframework.core.env.Environment;
1312
import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor;
@@ -18,7 +17,7 @@
1817

1918
import com.google.common.base.Preconditions;
2019

21-
@Configuration
20+
// @Configuration
2221
@EnableTransactionManagement
2322
@PropertySource({ "classpath:persistence-mysql.properties" })
2423
@ComponentScan({ "org.baeldung.spring.persistence.dao", "org.baeldung.spring.persistence.service" })

spring-all/src/main/java/org/baeldung/spring/config/WebConfig.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package org.baeldung.spring.config;
22

3+
import org.springframework.beans.factory.BeanFactory;
4+
import org.springframework.beans.factory.annotation.Autowired;
35
import org.springframework.context.annotation.ComponentScan;
46
import org.springframework.context.annotation.Configuration;
57
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
@@ -10,10 +12,11 @@
1012
@ComponentScan("org.baeldung.web")
1113
public class WebConfig extends WebMvcConfigurerAdapter {
1214

15+
@Autowired
16+
BeanFactory beanFactory;
17+
1318
public WebConfig() {
1419
super();
1520
}
1621

17-
18-
1922
}
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
package org.baeldung.web;
22

33
import org.springframework.stereotype.Component;
4+
import org.springframework.transaction.annotation.Transactional;
45

56
@Component
7+
@Transactional
68
public class BeanA {
79

8-
private IBeanC dependency;
9-
1010
public BeanA() {
1111
super();
1212
}
1313

14-
//
15-
1614
}

spring-all/src/main/java/org/baeldung/web/BeanB.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
package org.baeldung.web;
22

3+
import org.springframework.beans.factory.annotation.Autowired;
34
import org.springframework.stereotype.Component;
5+
import org.springframework.transaction.annotation.Transactional;
46

57
@Component
6-
public class BeanB implements IBeanB {
8+
@Transactional
9+
public class BeanB {
10+
11+
@Autowired
12+
private BeanA beanA;
713

814
public BeanB() {
915
super();

spring-all/src/main/java/org/baeldung/web/BeanC2.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import org.springframework.stereotype.Component;
44

55
@Component
6-
public class BeanC2 implements IBeanB {
6+
public class BeanC2 implements IBeanC {
77

88
public BeanC2() {
99
super();
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package org.baeldung.web;
2+
3+
public interface IBeanA {
4+
//
5+
}

spring-all/src/main/resources/beansInXml.xml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
55
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd">
66

7-
<bean id="beanA" class="org.baeldung.web.BeanA">
8-
<property name="beanC" ref="beanC" />
9-
</bean>
7+
<!-- <bean id="beanA" abstract="true" class="org.baeldung.web.BeanA" /> -->
108

119
</beans>

0 commit comments

Comments
 (0)