我正在开发一个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...");
}
}
我的bean配置文件如下;
<?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>
非常感谢任何帮助。
答案 0 :(得分:2)
看起来你导入错误了:
import org.apache.xbean.spring.context.ClassPathXmlApplicationContext;
但应该是:
import org.springframework.context.support.ClassPathXmlApplicationContext;