bean work

This commit is contained in:
eugenp
2013-05-25 01:10:44 +03:00
parent 94f9a60da1
commit 343a743229
7 changed files with 22 additions and 13 deletions
@@ -7,7 +7,6 @@ import javax.sql.DataSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.core.env.Environment;
import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor;
@@ -18,7 +17,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
import com.google.common.base.Preconditions;
@Configuration
// @Configuration
@EnableTransactionManagement
@PropertySource({ "classpath:persistence-mysql.properties" })
@ComponentScan({ "org.baeldung.spring.persistence.dao", "org.baeldung.spring.persistence.service" })
@@ -1,5 +1,7 @@
package org.baeldung.spring.config;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
@@ -10,10 +12,11 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
@ComponentScan("org.baeldung.web")
public class WebConfig extends WebMvcConfigurerAdapter {
@Autowired
BeanFactory beanFactory;
public WebConfig() {
super();
}
}
@@ -1,16 +1,14 @@
package org.baeldung.web;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
@Component
@Transactional
public class BeanA {
private IBeanC dependency;
public BeanA() {
super();
}
//
}
@@ -1,9 +1,15 @@
package org.baeldung.web;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
@Component
public class BeanB implements IBeanB {
@Transactional
public class BeanB {
@Autowired
private BeanA beanA;
public BeanB() {
super();
@@ -3,7 +3,7 @@ package org.baeldung.web;
import org.springframework.stereotype.Component;
@Component
public class BeanC2 implements IBeanB {
public class BeanC2 implements IBeanC {
public BeanC2() {
super();
@@ -0,0 +1,5 @@
package org.baeldung.web;
public interface IBeanA {
//
}