我在我的xml文件中配置了一个Spring bean但是当我运行我的应用程序时,我收到以下错误。谁能告诉我为什么?
org.springframework.beans.factory.BeanCreationException:错误 在文件中定义名为'ultra-config'的bean [C:\ src \ test \ resources \ conf \ ultra-root.xml]:bean的初始化 失败;嵌套异常是java.lang.NoSuchFieldError:NULL at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:529)
配置:
<bean id="http-8280" class="org.adroitlogic.ultraesb.transport.http.HttpNIOListener">
<constructor-arg ref="fileCache"/>
<property name="port" value="8280"/>
</bean>
<bean id="http-sender" class="org.adroitlogic.ultraesb.transport.http.HttpNIOSender">
<constructor-arg ref="fileCache"/>
</bean>
<bean id="environment" class="org.adroitlogic.ultraesb.api.Environment">
<constructor-arg value="unit_test" type="java.lang.String"/>
<property name="deploymentUnitsEnabled" value="true"/>
</bean>
<bean id="ultra-config" class="org.adroitlogic.ultraesb.core.ConfigurationImpl">
<property name="environment" ref="environment"/>
</bean>
Gradle依赖
dependencies {
testCompile group: 'org.mockito', name: 'mockito-all', version: '1.9.5'
testCompile group: 'org.apache.maven.plugins', name: 'maven-failsafe-plugin', version: '2.16'
testCompile group: 'junit', name: 'junit', version:'4.9'
testCompile group: 'org.adroitlogic', name: 'ultraesb-sample', version:'2.2.0-SNAPSHOT'
compile group: 'org.adroitlogic', name: 'ultraesb-api', version:'2.2.0-SNAPSHOT'
compile group: 'org.adroitlogic', name: 'logging-api', version:'1.0.0-SNAPSHOT'
compile group: 'org.adroitlogic', name: 'logging-slf4j-impl', version:'1.0.0-SNAPSHOT'
compile(group: 'org.springframework.security', name: 'spring-security-core', version:'3.1.4.RELEASE') {
exclude(module: 'spring-core')
exclude(module: 'spring-context')
exclude(module: 'spring-beans')
}
}
答案 0 :(得分:0)
使用不同的库版本可能会产生该错误。看看这个:
http://www.captaindebug.com/2013/05/spring-and-javalangnosuchfielderror.html#.U1vE7B__6b4
Spring 3.1 entityManagerFactory java.lang.NoSuchFieldError: NULL Error
答案 1 :(得分:0)
我认为我的IDE处于关于库的错误状态。我删除了我的项目并重新添加它,现在我已经通过了这个问题。