bean work
This commit is contained in:
parent
7245aa572a
commit
8555b95268
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
|
@ -14,6 +14,6 @@ public class WebConfig extends WebMvcConfigurerAdapter {
|
|||
super();
|
||||
}
|
||||
|
||||
// API
|
||||
|
||||
|
||||
}
|
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
package org.baeldung.web;
|
||||
|
||||
public abstract class BeanD implements IBeanD {
|
||||
|
||||
public BeanD() {
|
||||
super();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
package org.baeldung.web;
|
||||
|
||||
public interface IBeanD {
|
||||
//
|
||||
}
|
|
@ -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>
|
Loading…
Reference in New Issue