bean work

This commit is contained in:
eugenp
2013-05-24 23:14:34 +03:00
parent 8b070d278b
commit 7245aa572a
9 changed files with 56 additions and 9 deletions
@@ -23,7 +23,7 @@ public class MainWebAppInitializer implements WebApplicationInitializer {
// Create the 'root' Spring application context
final AnnotationConfigWebApplicationContext root = new AnnotationConfigWebApplicationContext();
root.scan("org.baeldung.spring.web.config");
root.scan("org.baeldung.spring.config");
// root.getEnvironment().setDefaultProfiles("embedded");
// Manages the lifecycle of the root application context
@@ -1,16 +1,24 @@
package org.baeldung.web;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
public class BeanA {
public class BeanA implements InitializingBean {
@Autowired
private IBeanB b;
private IBeanC dependency;
public BeanA() {
super();
}
//
@Override
public void afterPropertiesSet() throws Exception {
System.out.println();
}
}
@@ -0,0 +1,12 @@
package org.baeldung.web;
import org.springframework.stereotype.Component;
@Component
public class BeanB1 implements IBeanB {
public BeanB1() {
super();
}
}
@@ -0,0 +1,12 @@
package org.baeldung.web;
import org.springframework.stereotype.Component;
@Component
public class BeanB2 implements IBeanB {
public BeanB2() {
super();
}
}
@@ -5,9 +5,9 @@ import org.springframework.transaction.annotation.Transactional;
@Component
@Transactional
public class BeanB implements IBeanB {
public class BeanC implements IBeanC {
public BeanB() {
public BeanC() {
super();
}
@@ -0,0 +1,5 @@
package org.baeldung.web;
public interface IBeanC {
//
}