有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java组织。springframework。豆。工厂BeanDefinitionStoreException:

我得到下面的错误:当运行下面的代码。我只有src/main/resources文件夹中的xml文件(report context.xml)。不知道为什么它不起作用?这是maven项目

public static void main(String[] args) {
        int execResult = -1;
        ApplicationContext appCont = new ClassPathXmlApplicationContext(
                "classpath:/report-context.xml");
        Application appBean = (Application) appCont.getBean("abcLauncher");
        if (appBean != null) {
            appBean.run();
            execResult = appBean.resultCode();
        }
        System.exit(execResult);

    }

错误:

org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML
document from class path resource [report-context.xml]; 
nested exception is  java.io.FileNotFoundException: class path resource [beans xml file   
name]cannot be opened because it does not exist

如果我将代码行更改为:

ApplicationContext appCont = new ClassPathXmlApplicationContext(
                "classpath*:/report-context.xml");

虽然bean已经在xml文件中配置,但它给出了以下错误

Exception in thread "main"
org.springframework.beans.factory.NoSuchBeanDefinitionException: 
No bean named 'abcLauncher' is defined

感谢您在这方面的帮助

--添加我的xml文件的内容部分

<bean id="analystMeterDataServices" class="com.abc.pg.analystmeter.service.AnalystMeterDataServicesImpl">
        <property name="messageSender" ref="messageSender" />
        <property name="analystMeterDao" ref="analystMeterDao" />
        <property name="dataFileName"
            value="${data.dir}${data.smselector.paramsfilename}" />
        <property name="lastRunDateformat" value="${data.lastrundateformat}" /> 
    </bean>

    <bean id="abcLauncher" class="com.abc.pg.analystmeter.AnalystMeterLauncher">
        <property name="appSelectorDataServices" ref="analystMeterDataServices" />
    </bean>

共 (0) 个答案