gpt4 book ai didi

spring - 在命令行中运行 spring 应用程序时无法识别的 xbean 命名空间映射异常

转载 作者:行者123 更新时间:2023-12-04 16:51:27 24 4
gpt4 key购买 nike

我正在开发一个 spring 命令行应用程序并且在 Eclipse 中运行良好。但是在命令行中我收到以下错误;

Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStore
Exception: Unrecognized xbean namespace mapping: http://www.springframework.org/
schema/aop
at org.apache.xbean.spring.context.v2c.XBeanNamespaceHandler.parseBeanFromExtensionElement(XBeanNamespaceHandler.java:284)
at org.apache.xbean.spring.context.v2c.XBeanNamespaceHandler.parse(XBeanNamespaceHandler.java:156)
at org.apache.xbean.spring.context.v2.XBeanNamespaceHandler.parse(XBeanNamespaceHandler.java:49)
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1419)
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1409)
at org.apache.xbean.spring.context.v2.XBeanBeanDefinitionDocumentReader.parseBeanDefinitions(XBeanBeanDefinitionDocumentReader.java:84)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.doRegisterBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:140)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:111)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:493)
at org.apache.xbean.spring.context.v2.XBeanXmlBeanDefinitionReader.registerBeanDefinitions(XBeanXmlBeanDefinitionReader.java:79)

代码:
import org.apache.xbean.spring.context.ClassPathXmlApplicationContext;
import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.stereotype.Component;

@Component
public class SpringCommandLine {

private static final String APP_CONTEXT_PATH = "classpath:/BatchClientBeans.xml";

public static void main(String[] args) {

AbstractApplicationContext context = new ClassPathXmlApplicationContext(APP_CONTEXT_PATH);
context.registerShutdownHook();

BatchClientDAO batchClientDAOBean = (BatchClientDAO) context.getBean("batchClientDAOBean");
System.out.println("Next batch ID: " + batchClientDAOBean.getNextBatchId());

System.out.println("Exiting...");

}

}

我的beans配置文件如下;
<?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:camel="http://camel.apache.org/schema/spring"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
">

<bean id="batchClientDAOBean" class="com.test.data_analysis.client.BatchClientDAOImpl">
<property name="sqlMapClientTemplate" ref="sqlMapClientTemplateLocal" />
</bean>
</beans>

任何帮助将不胜感激。

最佳答案

看起来你有错误的导入:

import org.apache.xbean.spring.context.ClassPathXmlApplicationContext;

但应该是:
import org.springframework.context.support.ClassPathXmlApplicationContext;

关于spring - 在命令行中运行 spring 应用程序时无法识别的 xbean 命名空间映射异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22532464/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com