further exceptions work

This commit is contained in:
eugenp 2013-08-11 15:54:26 +03:00
parent 429fe66727
commit 075dd7be5c
14 changed files with 160 additions and 0 deletions

View File

@ -0,0 +1,8 @@
package org.baeldung.ex.beancreationexception.cause6;
import org.springframework.stereotype.Component;
@Component
public class BeanA {
private IBeanB dependency;
}

View File

@ -0,0 +1,8 @@
package org.baeldung.ex.beancreationexception.cause6;
import org.springframework.stereotype.Component;
@Component
public class BeanB implements IBeanB {
//
}

View File

@ -0,0 +1,5 @@
package org.baeldung.ex.beancreationexception.cause6;
public interface IBeanB {
//
}

View File

@ -0,0 +1,16 @@
package org.baeldung.ex.beancreationexception.cause8;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
public class BeanA implements IBeanA {
private IBeanB beanB;
@Autowired
public BeanA(final IBeanB beanB) {
super();
this.beanB = beanB;
}
}

View File

@ -0,0 +1,15 @@
package org.baeldung.ex.beancreationexception.cause8;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
public class BeanB implements IBeanB {
final IBeanA beanA;
@Autowired
public BeanB(final IBeanA beanA) {
super();
this.beanA = beanA;
}
}

View File

@ -0,0 +1,5 @@
package org.baeldung.ex.beancreationexception.cause8;
public interface IBeanA {
//
}

View File

@ -0,0 +1,5 @@
package org.baeldung.ex.beancreationexception.cause8;
public interface IBeanB {
//
}

View File

@ -2,9 +2,11 @@ package org.baeldung.ex.beancreationexception.spring;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportResource;
@Configuration
@ComponentScan("org.baeldung.ex.beancreationexception.cause6")
@ImportResource("classpath:beancreationexception_cause6.xml")
public class Cause6ContextWithJavaConfig {
public Cause6ContextWithJavaConfig() {

View File

@ -0,0 +1,18 @@
package org.baeldung.ex.beancreationexception.spring;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportResource;
@Configuration
@ComponentScan("org.baeldung.ex.beancreationexception.cause7")
@ImportResource("classpath:beancreationexception_cause7.xml")
public class Cause7ContextWithJavaConfig {
public Cause7ContextWithJavaConfig() {
super();
}
// beans
}

View File

@ -0,0 +1,16 @@
package org.baeldung.ex.beancreationexception.spring;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
@Configuration
@ComponentScan("org.baeldung.ex.beancreationexception.cause8")
public class Cause8ContextWithJavaConfig {
public Cause8ContextWithJavaConfig() {
super();
}
// beans
}

View File

@ -0,0 +1,13 @@
<?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"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-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.ex.beancreationexception.cause6.BeanA">
<property name="beanB" ref="beanB" />
</bean>
</beans>

View File

@ -0,0 +1,11 @@
<?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"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.2.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd">
<bean id="beanZ" class="org.baeldung.ex.beancreationexception.cause7.BeanZ" />
</beans>

View File

@ -0,0 +1,19 @@
package org.baeldung.ex.beancreationexception;
import org.baeldung.ex.beancreationexception.spring.Cause7ContextWithJavaConfig;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.support.AnnotationConfigContextLoader;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = { Cause7ContextWithJavaConfig.class }, loader = AnnotationConfigContextLoader.class)
public class Cause7BeanCreationExceptionIntegrationTest {
@Test
public final void givenContextIsInitialized_thenNoException() {
//
}
}

View File

@ -0,0 +1,19 @@
package org.baeldung.ex.beancreationexception;
import org.baeldung.ex.beancreationexception.spring.Cause8ContextWithJavaConfig;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.support.AnnotationConfigContextLoader;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = { Cause8ContextWithJavaConfig.class }, loader = AnnotationConfigContextLoader.class)
public class Cause8BeanCreationExceptionIntegrationTest {
@Test
public final void givenContextIsInitialized_thenNoException() {
//
}
}