存储库:审计属性无法解析为 (n) 属性组组件 [英] repository:auditing-attributes cannot be resolved to a(n) attribute group component

查看:25
本文介绍了存储库:审计属性无法解析为 (n) 属性组组件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将 Spring 数据库,特别是 Spring 存储库,放入 Java 遗留应用程序 (Java 1.6) 中.遗留应用程序也在使用 Ant 构建,并且在加载 Spring ApplicationContext 时出现以下错误.

Getting the Spring Data library, specifically Spring Repositories, into a Java legacy application(Java 1.6). The legacy application is using an Ant build as well and I am getting the following error when the Spring ApplicationContext is being loaded.

org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 43 in XML document from ServletContext resource [/WEB-INF/spring/beans/cycpersistence-beans.xml] is invalid; nested exception is org.xml.sax.SAXParseException: src-resolve: Cannot resolve the name 'repository:auditing-attributes' to a(n) 'attribute group' component.
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:399)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:399)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:336)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:304)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:181)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:217)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:188)
at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:125)
at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:94)
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:129)
at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:612)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:513)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:444)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:326)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3910)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4389)
at org.jboss.web.tomcat.service.deployers.TomcatDeployment.performDeployInternal(TomcatDeployment.java:313)
at org.jboss.web.tomcat.service.deployers.TomcatDeployment.performDeploy(TomcatDeployment.java:145)
at org.jboss.web.deployers.AbstractWarDeployment.start(AbstractWarDeployment.java:461)
at org.jboss.web.deployers.WebModule.startModule(WebModule.java:122)
at org.jboss.web.deployers.WebModule.start(WebModule.java:97)
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:597)
at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:157)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:96)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:668)
at org.jboss.system.microcontainer.ServiceProxy.invoke(ServiceProxy.java:206)
at com.sun.proxy.$Proxy38.start(Unknown Source)
at org.jboss.system.microcontainer.StartStopLifecycleAction.installAction(StartStopLifecycleAction.java:42)
at org.jboss.system.microcontainer.StartStopLifecycleAction.installAction(StartStopLifecycleAction.java:37)
at org.jboss.dependency.plugins.action.SimpleControllerContextAction.simpleInstallAction(SimpleControllerContextAction.java:62)
at org.jboss.dependency.plugins.action.AccessControllerContextAction.install(AccessControllerContextAction.java:71)
at org.jboss.dependency.plugins.AbstractControllerContextActions.install(AbstractControllerContextActions.java:51)
at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
at org.jboss.system.microcontainer.ServiceControllerContext.install(ServiceControllerContext.java:297)
at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1652)
at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:938)
at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)
at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:988)
at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:826)
at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:556)
at org.jboss.system.ServiceController.doChange(ServiceController.java:688)
at org.jboss.system.ServiceController.start(ServiceController.java:460)
at org.jboss.system.deployers.ServiceDeployer.start(ServiceDeployer.java:163)
at org.jboss.system.deployers.ServiceDeployer.deploy(ServiceDeployer.java:99)
at org.jboss.system.deployers.ServiceDeployer.deploy(ServiceDeployer.java:46)
at org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer.internalDeploy(AbstractSimpleRealDeployer.java:62)
at org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer.deploy(AbstractRealDeployer.java:55)
at org.jboss.deployers.plugins.deployers.DeployerWrapper.deploy(DeployerWrapper.java:179)
at org.jboss.deployers.plugins.deployers.DeployersImpl.doDeploy(DeployersImpl.java:1454)
at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1172)
at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1193)
at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1225)
at org.jboss.deployers.plugins.deployers.DeployersImpl.install(DeployersImpl.java:1113)
at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1652)
at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:938)
at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)
at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:988)
at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:826)
at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:556)
at org.jboss.deployers.plugins.deployers.DeployersImpl.process(DeployersImpl.java:789)
at org.jboss.deployers.plugins.main.MainDeployerImpl.process(MainDeployerImpl.java:699)
at org.jboss.system.server.profileservice.repository.MainDeployerAdapter.process(MainDeployerAdapter.java:117)
at org.jboss.system.server.profileservice.repository.ProfileDeployAction.install(ProfileDeployAction.java:70)
at org.jboss.system.server.profileservice.repository.AbstractProfileAction.install(AbstractProfileAction.java:53)
at org.jboss.system.server.profileservice.repository.AbstractProfileService.install(AbstractProfileService.java:403)
at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1652)
at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:938)
at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)
at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:988)
at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:778)
at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:543)
at org.jboss.system.server.profileservice.repository.AbstractProfileService.registerProfile(AbstractProfileService.java:308)
at org.jboss.system.server.profileservice.ProfileServiceBootstrap.start(ProfileServiceBootstrap.java:256)
at org.jboss.bootstrap.AbstractServerImpl.start(AbstractServerImpl.java:461)
at org.jboss.Main.boot(Main.java:229)

这是我正在使用的 Spring 库,spring-data-commons-core.jar 之外的所有版本都对应于 Spring.io 站点的 Hopper-SR10 发布系列.所有经过验证都在类路径上

Here are the Spring libraries I'm using, all versions outside of spring-data-commons-core.jar corresponding to the Hopper-SR10 release train from the Spring.io site. All are verified to be on the classpath

        <!-- New Spring, Spring Data, Spring JPA, Spring ORM Libs-->
    <pathelement location="${compile.lib}/spring-core-4.2.9.RELEASE.jar"/>
    <pathelement location="${compile.lib}/spring-data-jpa-1.10.10.RELEASE.jar"/>
    <pathelement location="${compile.lib}/spring-data-commons-1.12.10.RELEASE.jar"/>
    <pathelement location="${compile.lib}/spring-orm-4.2.9.RELEASE.jar"/>
    <pathelement location="${compile.lib}/spring-aop-4.2.9.RELEASE.jar"/>
    <pathelement location="${compile.lib}/spring-aspects-4.2.9.RELEASE.jar"/>
    <pathelement location="${compile.lib}/spring-jdbc-4.2.9.RELEASE.jar"/>
    <pathelement location="${compile.lib}/spring-beans-4.2.9.RELEASE.jar"/>
    <pathelement location="${compile.lib}/spring-web-4.2.9.RELEASE.jar"/>
    <pathelement location="${compile.lib}/spring-context-4.2.9.RELEASE.jar"/>
    <pathelement location="${compile.lib}/spring-expression-4.2.9.RELEASE.jar"/>
    <pathelement location="${compile.lib}/spring-data-commons-core-1.4.1.RELEASE.jar"/>

这是Spring配置xml:

Here is the Spring configuration xml:

    <?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:jpa="http://www.springframework.org/schema/data/jpa"
    xsi:schemaLocation="http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context-4.2.xsd
    http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
    http://www.springframework.org/schema/data/repository
    http://www.springframework.org/schema/data/repository/spring-repository.xsd
    http://www.springframework.org/schema/data/jpa
    http://www.springframework.org/schema/data/jpa/spring-jpa.xsd
 ">

    <context:component-scan base-package="com.cc.spring.beans.persistence, com.cc.spring.beans.persistence.repository"/>
    <jpa:repositories base-package="com.cc.spring.beans.persistence.repository"/>

</beans>

之前的 Stack Overflow 帖子已经提到这可能是由于 Spring Data jar 文件不兼容,但我再次使用 Spring 发布系列来避免这种情况.我在 xml 文件中使用了不同版本的 spring-data xsd 架构,但没有成功.我已经删除并添加了 spring 存储库 xsd 架构.在前进的过程中,任何和所有想法都将不胜感激.

Previous Stack Overflow posts have mentioned that it can be due to incompatible spring Data jar files, but again I used the Spring release train to avoid that very situation. I have used different versions of the spring-data xsd schema in the xml file with no success. I have removed and added the spring repository xsd schema. Any and all ideas will be very appreciated in moving forward.

推荐答案

问题解决了,归结为挖掘错误而不是随机尝试类似问题的答案.它找不到 XML 属性组repository:auditing-attributes".然后我挖掘了 Spring Data Commons 1.12.10 的 jar 文件,发现它包含 spring-repository-1.8.xsd.我在 xml cycpersistenance.xml 中指定了该版本,并且它起作用了.

The issue is solved, it boiled down to digging into the error rather than just randomly trying answers to similar questions. It couldn't find the XML attribute group "repository:auditing-attributes". I then dug into the jar file for Spring Data Commons 1.12.10 and found that it contained spring-repository-1.8.xsd. I specified that version in the xml, cycpersistenance.xml, and it worked.

查看 xsd 以了解它被引用的位置以及错误的来源:http://www.springframework.org/schema/data/jpa/spring-jpa.xsd

Look at the xsd to see where it is being referenced and where the error was coming from: http://www.springframework.org/schema/data/jpa/spring-jpa.xsd

<xsd:complexType>
<xsd:attributeGroup ref="repository:auditing-attributes"/>
</xsd:complexType>

然后在 http://www.springframework.org/schema/data/repository/spring-repository-1.8.xsd.它在复杂组repository

And then the definition found here in http://www.springframework.org/schema/data/repository/spring-repository-1.8.xsd. It is under the complex group "repository

这篇关于存储库:审计属性无法解析为 (n) 属性组组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆