I am getting below error: when running the below code. I have he xml file(report-context.xml) at src/main/resources folder only. Not sure why is it not working? it is maven project.
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);
}
Error:
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
if i change the line of code to :
ApplicationContext appCont = new ClassPathXmlApplicationContext(
"classpath*:/report-context.xml");
It gives below error though the bean is already configured in xml file?
Exception in thread "main"
org.springframework.beans.factory.NoSuchBeanDefinitionException:
No bean named 'abcLauncher' is defined
Appreciated any help on this
--adding content part of my xml file
<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>