以下代码是一段代码,而不是完整的代码:
SystemConfigDAO.java
package com.model.dao.systemconfig;
@Component( "syncSystemConfigDAO" )
@DependsOn({"dao.DAOFramework"})
public class SystemConfigDAO {
private static final Logger LOGGER = Logger.getLogger(SystemConfigDAO.class);
/**
* Default connection to database
*/
public SystemConfigDAO() {
this(DAOFramework.getInstance());
}
}
SystemConfigManager.java
package com.manager.systemconfig;
@Component
@ComponentScan( basePackages = "com.model.dao.systemconfig" )
@Scope("singleton")
@DependsOn({"dao.DAOFramework"})
public class SystemConfigManager {
private static final Logger LOGGER = Logger.getLogger(SystemConfigManager.class);
@Autowired
SystemConfigDAO systemConfigDAO;
public void saveValue(String key, Long tenant, Long user, ConfigValue value){
if (value == null) {
systemConfigDAO.removeValue(key, tenant, user);
} else {
systemConfigDAO.saveValue(key, tenant, user, value.getValue(), value.getType(), value.getLastModified());
}
}
}
DAOFramework.java
package com.dal;
public class DAOFramework {
private static volatile ApplicationContext context;
/**
* Declare Spring id for default framework instance
*/
public static final String FRAMEWORK_BEAN_NAME="dao.DAOFramework";
@Autowired(required = true)
public void setApplicationContext(ApplicationContext applicationContext) {
context = applicationContext;
}
public static ApplicationContext getApplicationContext() {
return context;
}
AtomicReference<Morphia> _morphia = new AtomicReference<Morphia>();
/**
*
* @return default instance of DAO framework
*/
public static DAOFramework getInstance(){
return (DAOFramework) getApplicationContext().getBean(FRAMEWORK_BEAN_NAME);
}
public static Object getBean(String beanName){
return getApplicationContext().getBean(beanName);
}
public void setConnection(MongoClient mongo){
_connection.compareAndSet(null, mongo);
}
AtomicReference<MongoClient> _connection = new AtomicReference<MongoClient>();
private String _DBName;
/**
* Connection to MongoDB shared per multiple threads. Per mongo's doc:
* "The Mongo object instance actually represents a pool of connections
* to the database; you will only need one object of class Mongo even with multiple threads."
* @return single instance of Mongo
*/
public MongoClient getConnection(){
return _connection.get();
}
/**
* Deprecating in favor of mongo3 MongoDatabase
* @return default pre-configured database
*/
@Deprecated
public DB getDB(){
return getConnection().getDB(getDBName());
}
public MongoDatabase getDatabase()
{
return getConnection().getDatabase(getDBName());
}
/**
*
* @return name of default database used by entire project
*/
public String getDBName() {
return _DBName;
}
public void setDBName(String dBName) {
this._DBName = dBName;
}
List<String> _entityPackages;
/**
* @return list of packages to locate entities for Morphia
*/
public List<String> getEntityPackages() {
return _entityPackages;
}
/**
* @param entityPackages new list of entities
*/
public void setEntityPackages(List<String> entityPackages) {
this._entityPackages = entityPackages;
}
/**
* Get single instance of Morphia. It is thread-safe per google comment (http://groups.google.com/group/morphia/browse_thread/thread/bc981e664b9f04d5)
* @return application-wide single instance of Morphia
*/
public Morphia getMorphia() {
if( _morphia.get() == null ){//no morphia initialized yet
Morphia morphia = new Morphia();
//first time need assign entities mappings
for(String pack : getEntityPackages()){//iterate all packages to locate entities
for(Class<?> c : EntityDiscover.getClassesInPackage(pack, ".+Entity$")){
morphia.map(c);
}
}
//assign only thread-safe way
_morphia.compareAndSet(null, morphia);
}
/**/
return _morphia.get();
}
/**
* Create Morphia-like DAO class instance with specified entity
* @param entity type will be used for serialize/deserialize operations
* @return instance that can be used for morphia manipulation with entity. This instance is shared
* between multiple threads.
*/
public DAOExtension createDAO(Class entity){
return DAOExtension.getInstance(entity, this);
}
}
spring.xml
<context:annotation-config/>
<context:component-scan base-package="com.model.*"/>
<bean id="dao.daoFramework.entityPackages" class="java.util.ArrayList">
<constructor-arg>
<list value-type="java.lang.String">
<value>com.model.entity</value>
</list>
</constructor-arg>
</bean>
<import resource="spring-db.xml"/>
弹簧db.xml
<context:component-scan base-package="com.dal.*" />
<context:component-scan base-package="com.model.dao."/>
<context:component-scan base-package="com.manager."></context:component-scan>
<context:annotation-config />
<bean id="dao.DAOFramework" class="com.dal.DAOFramework">
<property name="connection" ref="mongoClient"/>
<property name="DBName" value="${mongo-db}"/>
<property name="entityPackages">
<ref bean="dao.daoFramework.entityPackages" />
</property>
</bean>
<bean id="mongoClient" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
<property name="targetObject"><ref local="mongoFactory"/></property>
<property name="targetMethod"><value>getMongoClient</value></property>
</bean>
<bean id="mongoFactory" class="com.stratasync.dal.MongoFactory">
<property name="connectionsPerHost" value="${mongo-connections}"></property>
<property name="autoConnectRetry" value="${mongo-autoConnectRetry}"></property>
<property name="socketKeepAlive" value="true"></property>
<property name="threadsAllowedToBlockForConnectionMultiplier" value="${mongo-connectionsBacklog}"></property>
<property name="mongoHosts">
<list>
<bean class="com.mongodb.ServerAddress">
<constructor-arg value="${mongo-host1}"></constructor-arg>
</bean>
<bean class="com.mongodb.ServerAddress">
<constructor-arg value="${mongo-host2}"></constructor-arg>
</bean>
<bean class="com.mongodb.ServerAddress">
<constructor-arg value="${mongo-host3}"></constructor-arg>
</bean>
</list>
</property>
<property name="mongoCredentials">
<list>
<ref bean="mongoCredentialID"/>
</list>
</property>
<property name="writeConcern">
<bean id="com.mongodb.WriteConcern.ACKNOWLEDGED" class="org.springframework.beans.factory.config.FieldRetrievingFactoryBean">
</bean>
</property>
</bean>
引起:
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'systemConfigManager': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.model.dao.systemconfig.SystemConfigDAO com.manager.systemconfig.SystemConfigManager.systemConfigDAO; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'syncSystemConfigDAO' defined in URL [jar:file:/C:/apache-tomcat-8.0.36/webapps/Universe/WEB-INF/lib/data-access-5.1.0.0.jar!/com/model/dao/systemconfig/SystemConfigDAO.class]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.model.dao.systemconfig.SystemConfigDAO]: Constructor threw exception; nested exception is java.lang.NullPointerException
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:288)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1122)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:522)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1117)
at com.stratasync.dal.DAOFramework.getBean(DAOFramework.java:45)
at com.beans.ServiceAndManagerBeansCollection.getSystemConfigManager(ServiceAndManagerBeansCollection.java:253)
at com.distconf.DistributedConfig.<init>(DistributedConfig.java:39)
at com.distconf.DistributedConfig.getInstance(DistributedConfig.java:51)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.util.MethodInvoker.invoke(MethodInvoker.java:273)
at org.springframework.beans.factory.config.MethodInvokingFactoryBean.doInvoke(MethodInvokingFactoryBean.java:162)
at org.springframework.beans.factory.config.MethodInvokingFactoryBean.afterPropertiesSet(MethodInvokingFactoryBean.java:152)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1547)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1485)
... 84 more
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.model.dao.systemconfig.SystemConfigDAO com.manager.systemconfig.SystemConfigManager.systemConfigDAO; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'syncSystemConfigDAO' defined in URL [jar:file:/C:/apache-tomcat-8.0.36/webapps/Universe/WEB-INF/lib/data-access-5.1.0.0.jar!/com/model/dao/systemconfig/SystemConfigDAO.class]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.model.dao.systemconfig.SystemConfigDAO]: Constructor threw exception; nested exception is java.lang.NullPointerException
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:514)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:285)
... 105 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'syncSystemConfigDAO' defined in URL [jar:file:/C:/apache-tomcat-8.0.36/webapps/Universe/WEB-INF/lib/data-access-5.1.0.0.jar!/com/model/dao/systemconfig/SystemConfigDAO.class]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.model.dao.systemconfig.SystemConfigDAO]: Constructor threw exception; nested exception is java.lang.NullPointerException
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1013)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:946)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:490)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:910)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:853)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:768)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:486)
... 107 more
Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.model.dao.systemconfig.SystemConfigDAO]: Constructor threw exception; nested exception is java.lang.NullPointerException
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:163)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:87)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1006)
... 118 more
Caused by: java.lang.NullPointerException
at com.dal.DAOFramework.getMorphia(DAOFramework.java:113)
at com.dal.DAOExtension.<init>(DAOExtension.java:111)
at com.dal.DAOExtension.createInstance(DAOExtension.java:145)
at com.dal.DAOExtension.getInstance(DAOExtension.java:135)
at com.model.dao.systemconfig.SystemConfigDAO.<init>(SystemConfigDAO.java:65)
at com.model.dao.systemconfig.SystemConfigDAO.<init>(SystemConfigDAO.java:56)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:148)
... 120 more
相关原因:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dao.DAOFramework' defined in ServletContext resource [/WEB-INF/spring/spring-db.xml]: Initialization of bean failed; nested exception is java.lang.IllegalArgumentException
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:532)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:285)
at org.springframework.beans.factory.support.AbstractBeanFactory.getTypeForFactoryBean(AbstractBeanFactory.java:1362)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getTypeForFactoryBean(AbstractAutowireCapableBeanFactory.java:726)
at org.springframework.beans.factory.support.AbstractBeanFactory.isTypeMatch(AbstractBeanFactory.java:523)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doGetBeanNamesForType(DefaultListableBeanFactory.java:357)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:335)
at org.springframework.beans.factory.BeanFactoryUtils.beanNamesForTypeIncludingAncestors(BeanFactoryUtils.java:187)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:895)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:853)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:768)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:486)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:285)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1122)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:522)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:323)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:107)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveManagedSet(BeanDefinitionValueResolver.java:366)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:158)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1393)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1134)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:522)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:323)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:107)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1393)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1134)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:522)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:626)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:389)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:294)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4842)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5303)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1407)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1397)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.IllegalArgumentException
at org.springframework.asm.ClassReader.<init>(Unknown Source)
at org.springframework.asm.ClassReader.<init>(Unknown Source)
at org.springframework.asm.ClassReader.<init>(Unknown Source)
at org.springframework.core.LocalVariableTableParameterNameDiscoverer.inspectClass(LocalVariableTableParameterNameDiscoverer.java:110)
at org.springframework.core.LocalVariableTableParameterNameDiscoverer.getParameterNames(LocalVariableTableParameterNameDiscoverer.java:85)
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:193)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1051)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:955)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:490)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:323)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:107)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1393)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1134)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:522)
... 62 more
尝试了在线提供的各种建议,在SystemCongiManager.java中添加了@ComponentScan
basePackage,并在component-scan
中添加了spring-db.xml
,但没有一个有效。我也试着保留两个选项,但仍然是同样的错误。请建议如何解决。