bean work

This commit is contained in:
eugenp 2013-05-24 23:32:25 +03:00
parent 7245aa572a
commit 8555b95268
7 changed files with 42 additions and 6 deletions

View File

@ -0,0 +1,15 @@
package org.baeldung.spring.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportResource;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
@Configuration
@ImportResource("classpath:beansInXml.xml")
public class CoreConfig extends WebMvcConfigurerAdapter {
public CoreConfig() {
super();
}
}

View File

@ -14,6 +14,6 @@ public class WebConfig extends WebMvcConfigurerAdapter {
super();
}
// API
}

View File

@ -1,14 +1,13 @@
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 implements InitializingBean {
@Autowired
private IBeanC dependency;
// @Autowired
// private IBeanC dependency;
public BeanA() {
super();
@ -19,6 +18,7 @@ public class BeanA implements InitializingBean {
@Override
public void afterPropertiesSet() throws Exception {
System.out.println();
// throw new NullPointerException();
}
}

View File

@ -1,10 +1,8 @@
package org.baeldung.web;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
@Component
@Transactional
public class BeanC implements IBeanC {
public BeanC() {

View File

@ -0,0 +1,9 @@
package org.baeldung.web;
public abstract class BeanD implements IBeanD {
public BeanD() {
super();
}
}

View File

@ -0,0 +1,5 @@
package org.baeldung.web;
public interface IBeanD {
//
}

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
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="beanD" class="org.baeldung.web.BeanD" />
</beans>