在application-context.xml中定义mongo存储库时遇到问题
以下是我在xml中得到的错误
Error occured processing XML tried to access method org.springframework.context.annotation.AnnotationConfigUtils.processCommonDefinitionAnnotations (Lorg/springframework/beans/factory/annotation/AnnotatedBeanDefinition;)V from class org.springframework.data.repository.config.RepositoryComponentProvider'. See Error Log for more details servlet-context.xml /master/WebContent/WEB- INF/config line 24 Spring Beans Problem
我附上env的屏幕截图,以供参考。我正在使用eclipse Kepler版本和pom属性文件是这样的
<java-version>1.7</java-version> <org.springframework-version>4.0.1.RELEASE</org.springframework-version> <org.jackson-version>2.3.0</org.jackson-version> <spring-data-mongodb>1.4.0.RELEASE</spring-data-mongodb>
Spring Data Commons版本是1.7 Spring Data Mongo DB版本1.4。打开上下文xml时,我在eclipse项目中看到错误。
有趣的是,我还有另一个运行良好的项目,唯一的区别是它没有Spring MVC和Jackson二进制文件,否则没有类似的项目。
异常堆栈跟踪:
!ENTRY org.springframework.ide.eclipse.beans.core 1 0 2014-03-01 00:04:11.839!MESSAGE处理’/master/WebContent/WEB-INF/config/servlet- context.xml’时出错!STACK 0 java.lang.IllegalAccessError:尝试从类org.springframework.data.repository.config.RepositoryComponentProvider中访问方法org.springframework.context.annotation.AnnotationConfigUtils.processCommonDefinitionAnnotations(Lorg / springframework / beans / factory / annotation / AnnotatedBeanDefinition;)V在org.springframework.data.repository.config.RepositoryComponentProvider.findCandidateComponents(RepositoryComponentProvider.java:121)在org.springframework.data.repository.config.RepositoryConfigurationSourceSupport.getCandidates(RepositoryConfigurationSourceSupport.java:69)在org.springframework.data.repository .config。org.springframework.data.repository.config.RepositoryConfigurationDelegate.registerRepositoriesIn(RepositoryConfigurationDelegate.java:88)的org.springframework.data.repository.config.RepositoryBeanDefinitionParser.parse(RepositoryConfigurationExtensionSupport.getRepositoryConfigurations(RepositoryConfigurationExtensionSupport.java:54) 67)在org.springframework.ide.eclipse.beans.core.internal.model.namespaces.DelegatingNamespaceHandlerResolver $ ElementTrackingNamespaceHandler.parse(DelegatingNamespaceHandlerResolver.org.org)中的org.springframework.beans.factory.xml.NamespaceHandlerSupport.parse(NamespaceHandlerSupport.java:74)。的org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1427)处的Java:177)。org.org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1417)的springframework.ide.eclipse.beans.core.internal.model.BeansConfig $ ErrorSuppressingBeanDefinitionParserDelegate.parseCustomElement(BeansConfig.java:1400)在org.org。 org.springframework.ide.eclipse.beans.core.internal.model.BeansConfig $ ToolingFriendlyBeanDefinitionDocumentReader.doRegisterBeanDefinitions(BeansConfig.java:1330)位于org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:187)。 org.springframework.beans.factory.xml.XmlBeanDefinitionReader上的springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:110)。org.springframework.ide.eclipse.beans.core.internal.model.BeansConfig $ 2.registerBeanDefinitions(BeansConfig.java:402)的org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions的registerBeanDefinitions(XmlBeanDefinitionReader.java:494) (XmlBeanDefinitionReader.java:391)在org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:335)在org.springframework.ide.eclipse.beans.core.internal.model.BeansConfig $ 2.loadBeanDefinitions(位于org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:303)的BeansConfig.java:388)402)位于org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:391)位于org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:335)位于org.springframework.ide位于org.springframework.beans.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:303)的.eclipse.beans.core.internal.model.BeansConfig $ 2.loadBeanDefinitions(BeansConfig.java:388)402)位于org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:391)位于org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:335)位于org.springframework.ide位于org.springframework.beans.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:303)的.eclipse.beans.core.internal.model.BeansConfig $ 2.loadBeanDefinitions(BeansConfig.java:388)org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:303)处的loadBeanDefinitions(BeansConfig.java:388)org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:303)处的loadBeanDefinitions(BeansConfig.java:388)
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:mongo="http://www.springframework.org/schema/data/mongo" xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/data/mongo http://www.springframework.org/schema/data/mongo/spring-mongo.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> <!-- Enables the Spring MVC @Controller programming model --> <mvc:annotation-driven /> <context:component-scan base-package="com.xxxx.yyyyy" /> <!-- Mongo DB Configuration --> <mongo:mongo id="mongo" host="monopolyvm3" port="27017" /> <mongo:db-factory dbname="test" mongo-ref="mongo" /> <mongo:db-factory id="mongoDbFactory" dbname="cloud" mongo-ref="mongo" /> <mongo:repositories base-package="com.xxxx.yyyyy" /> <bean id="mappingContext" class="org.springframework.data.mongodb.core.mapping.MongoMappingContext" /> <bean id="defaultMongoTypeMapper" class="org.springframework.data.mongodb.core.convert.DefaultMongoTypeMapper"> <constructor-arg name="typeKey"><null/></constructor-arg> </bean> <bean id="mappingMongoConverter" class="org.springframework.data.mongodb.core.convert.MappingMongoConverter"> <constructor-arg name="mongoDbFactory" ref="mongoDbFactory" /> <constructor-arg name="mappingContext" ref="mappingContext" /> <property name="typeMapper" ref="defaultMongoTypeMapper" /> </bean> <bean id="mongoTemplate" class="org.springframework.data.mongodb.core.MongoTemplate"> <constructor-arg ref="mongoDbFactory" /> <constructor-arg name="mongoConverter" ref="mappingMongoConverter" /> <property name="writeConcern" value="SAFE" /> </bean> </beans>
错误出现在下一行。
最后,我将spring jar版本更改为4.0.0,然后从maven存储库中删除了所有spring jar,并尝试再次(首先更新maven)进行构建。我非常确定它也可以与4.0.1弹簧罐一起使用。(我当时有另一个配置相同的项目,并且与4.0.1罐一起正常工作:))我将这个问题贡献给了Maven和Eclipse。我根本没有任何线索的一些问题。