当我想初始化 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.BeanDefinitionParsingException:配置问题:无法从 URL 位置导入 bean 定义 [classpath:alfresco/core-services-context.xml]
违规资源:类路径资源 [alfresco/application-context-core.xml];嵌套异常是 org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException:来自类路径资源 [alfresco/core-services-context.xml] 的 XML 文档中的第 587 行无效;嵌套异常是 org.xml.sax.SAXParseException;行号:587;列号:107;cvc-datatype-valid.1.2.1:“cm:constraintRegistry”不是“NCName”的有效值。
我的代码很简单:
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());
}
}
}
这是我的 POM.xml 文件的内容:
<?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>
我不知道为什么上面的代码会出现这些错误。请问你能帮我解决这个问题吗?