exception work
This commit is contained in:
@@ -1,5 +0,0 @@
|
||||
package org.baeldung.di.core;
|
||||
|
||||
public interface IBeanB {
|
||||
//
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package org.baeldung.di.spring;
|
||||
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
@ComponentScan("org.baeldung.di")
|
||||
public class ContextWithJavaConfig {
|
||||
|
||||
public ContextWithJavaConfig() {
|
||||
super();
|
||||
}
|
||||
|
||||
// beans
|
||||
|
||||
}
|
||||
+3
-5
@@ -1,14 +1,12 @@
|
||||
package org.baeldung.di.core;
|
||||
package org.baeldung.ex.nosuchbeandefinitionexception.cause1;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class BeanA {
|
||||
|
||||
@Autowired
|
||||
@Qualifier("beanB2")
|
||||
private IBeanB dependency;
|
||||
private BeanB dependency;
|
||||
|
||||
}
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
package org.baeldung.ex.nosuchbeandefinitionexception.cause1;
|
||||
|
||||
public class BeanB {
|
||||
//
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package org.baeldung.ex.nosuchbeandefinitionexception.cause3;
|
||||
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class BeanA implements InitializingBean {
|
||||
|
||||
@Autowired
|
||||
private ApplicationContext context;
|
||||
|
||||
@Override
|
||||
public final void afterPropertiesSet() {
|
||||
context.getBean("test");
|
||||
}
|
||||
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.baeldung.di.core;
|
||||
package org.baeldung.ex.nosuchbeandefinitionexception.cause3;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
package org.baeldung.ex.nosuchbeandefinitionexception.cause3;
|
||||
|
||||
public interface IBeanB {
|
||||
//
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package org.baeldung.ex.nosuchbeandefinitionexception.spring;
|
||||
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
@ComponentScan("org.baeldung.di.cause1")
|
||||
public class Cause1ContextWithJavaConfig {
|
||||
|
||||
public Cause1ContextWithJavaConfig() {
|
||||
super();
|
||||
}
|
||||
|
||||
// beans
|
||||
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package org.baeldung.ex.nosuchbeandefinitionexception.spring;
|
||||
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
@ComponentScan("org.baeldung.di.cause2")
|
||||
public class Cause2ContextWithJavaConfig {
|
||||
|
||||
public Cause2ContextWithJavaConfig() {
|
||||
super();
|
||||
}
|
||||
|
||||
// beans
|
||||
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package org.baeldung.ex.nosuchbeandefinitionexception.spring;
|
||||
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
@ComponentScan("org.baeldung.di.cause2")
|
||||
public class Cause3ContextWithJavaConfig {
|
||||
|
||||
public Cause3ContextWithJavaConfig() {
|
||||
super();
|
||||
}
|
||||
|
||||
// beans
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user