I have the following bean configuration.
Code:
@EnvironmentValueSource
@Configuration
public abstract class ApplicationConfiguration {
abstract
@ExternalValue("database_type")
String databaseType();
}
@Configuration
@AnnotationDrivenTx
@PropertiesValueSource(locations = "classpath:config.properties")
@Import({DataSourceConfiguration.class, ApplicationConfiguration.class})
@ComponentScan({"dao.impl", "service.impl"})
public abstract class JpaConfiguration extends ConfigurationSupport {
abstract
@ExternalBean
String databaseType();
//omitted other methods for clarity
}
I am getting the following error when I try to access the bean which uses databaseType(). I have imported the external bean too. Not sure what I am missing here.
Code:
Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public final java.lang.String config.JpaConfiguration$$EnhancerByCGLIB$$7c12f771.databasePlatform()] threw exception; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'databaseType' is defined
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:127)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:435)
... 147 more
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'databaseType' is defined
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:387)
at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:968)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:246)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:168)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:238)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
at org.springframework.config.java.internal.enhancement.CglibConfigurationEnhancer$ExternalBeanMethodInterceptor.doIntercept(CglibConfigurationEnhancer.java:188)
at org.springframework.config.java.internal.enhancement.CglibConfigurationEnhancer$AbstractMethodInterceptor.intercept(CglibConfigurationEnhancer.java:170)
at config.JpaConfiguration$$EnhancerByCGLIB$$7c12f771.databaseType(<generated>)
at config.JpaConfiguration.databasePlatform(JpaConfiguration.java:146)
at config.JpaConfiguration$$EnhancerByCGLIB$$7c12f771.CGLIB$databasePlatform$21(<generated>)
at config.JpaConfiguration$$EnhancerByCGLIB$$7c12f771$$FastClassByCGLIB$$d9791c9c.invoke(<generated>)
at net.sf.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:167)
at org.springframework.config.java.internal.enhancement.CglibConfigurationEnhancer$BeanMethodInterceptor.doIntercept(CglibConfigurationEnhancer.java:285)
at org.springframework.config.java.internal.enhancement.CglibConfigurationEnhancer$AbstractMethodInterceptor.intercept(CglibConfigurationEnhancer.java:170)
at config.JpaConfiguration$$EnhancerByCGLIB$$7c12f771.databasePlatform(<generated>)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:115)
... 148 more
Appreciate any help.
Thanks!
Arul