bean work
This commit is contained in:
parent
94f9a60da1
commit
343a743229
|
@ -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 {
|
||||
//
|
||||
}
|
|
@ -4,8 +4,6 @@
|
|||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
|
||||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd">
|
||||
|
||||
<bean id="beanA" class="org.baeldung.web.BeanA">
|
||||
<property name="beanC" ref="beanC" />
|
||||
</bean>
|
||||
<!-- <bean id="beanA" abstract="true" class="org.baeldung.web.BeanA" /> -->
|
||||
|
||||
</beans>
|
Loading…
Reference in New Issue