当我想初始化alfresco存储库版本6.x或7.x的应用程序上下文(我已经测试了最新版本7.78和版本6.57(时,我有这些错误:
配置问题:无法从URL位置导入BEAN定义[classPath:alfresco/application-context-core.xml]
有问题的资源:类路径资源[alfresco/application-context.xml];嵌套异常是org.springframework.beans.factory.parsing.parsing.beandefinitionparsingexception:配置问题:无法从URL位置导入bean定义[classpath [classpath:alfresco/core core-services-context.xml] 有问题的资源:类路径资源[alfresco/application-context-core.xml];嵌套的异常是org.springframework.beans.factory.xml.xmlbeandefinitionstoreexception:XML文档中的第587行,来自类Path Resources [alfresco/core-services-context.xml]是无效的;嵌套的异常是org.xml.sax.saxparseexception;亚麻布:587;柱子:107;CVC-DATATYPE-VALID.1.2.1:'cm:CondernTregistry'不是'ncname'的有效值。 我的代码非常简单: 这是我的pom.xml文件的内容: 我不知道为什么我对以上代码有这些错误。请你能帮我解决这个问题吗?public class AlfrescoApp {
public static void main(String[] args) {
try {
ServiceRegistry serviceRegistry = null;
ApplicationContext context = null;
context = new ClassPathXmlApplicationContext("alfresco/application-context.xml");
serviceRegistry = (ServiceRegistry) context.getBean(ServiceRegistry.SERVICE_REGISTRY);
AuthenticationUtil.setAdminUserAsFullyAuthenticatedUser();
NodeService nodeService = serviceRegistry.getNodeService();
} catch (Exception e) {
System.err.println(e.getMessage());
}
}
}
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.alfresco.project</groupId>
<artifactId>white_box_project_alfresco</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-repository</artifactId>
<version>7.78</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.32</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>4.1.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>4.1.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>4.1.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId>
<version>4.1.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>4.1.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-expression</artifactId>
<version>4.1.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>3.2.14.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>4.1.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
<version>2.5</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>Cp1252</encoding>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>alfresco-public</id>
<url>https://artifacts.alfresco.com/nexus/content/repositories/public/</url>
</repository>
<repository>
<id>jboss-public-repository-group</id>
<name>JBoss Public Repository Group</name>
<url>http://repository.jboss.org/nexus/content/groups/public/</url>
<releases>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<updatePolicy>daily</updatePolicy>
</snapshots>
</repository>
</repositories>
</project>
问题在于,您将pom.xml中的弹簧框架jar-s的各种版本混合在一起。为了解决此问题,只需从pom.xml中删除所有不必要的依赖项,并且不要使用春季的旧版本,例如"一对一" 2.5版。
旧的春季版本似乎不允许":" bean标识符( ncname type type toblebids tobe this this,be Concrete(。在您提供的错误输出中提到的" alfresco/core-services-context.xml"中定义的bean之一是这种情况:
<bean id="cm:constraintRegistry" class="org.alfresco.repo.dictionary.constraint.ConstraintRegistry" />
如果您查看alfresco-repository-7.78.jar的pom.xml,您将看到它依赖于春季版本5.1.8.Release-为了避免问题,请尝试在项目中使用非常相同的版本好。