I try to write a simple Spring 3 console application. I Cant get this application to run, i always get the error, that there is no main method. My system is an Ubuntu 12.04 with openjdk-7 installed, and the sts 2.9.2-release. A simple hello world runs without any problems Edit:(i tested a other project to prove a simple hello world would run).
The Project is managed over maven and i got no errors so far.
I try to reproduce an exsample of a book as follow:
XmlConfigWithBeanFactory.java
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.core.io.FileSystemResource;
public class XmlConfigWithBeanFactory {
public static void main(String[] args) {
DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
XmlBeanDefinitionReader rdr = new XmlBeanDefinitionReader(factory);
rdr.loadBeanDefinitions(new FileSystemResource(
"src/xmlBeanFactory.xml"));
Oracle oracle = (Oracle) factory.getBean("oracle");
System.out.println(oracle.defineMeaningOfLife());
}
}
Oracle.java
public interface Oracle {
public String defineMeaningOfLife();
}
BookwormOracle.java
public class BookwormOracle implements Oracle {
public String defineMeaningOfLife() {
return "Encyclopedias are a waste of money - use the Internet";
}
}
xmlBeanFactory.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">
<!-- oracle bean used for a few examples -->
<bean id="oracle" name="wiseworm" class="BookwormOracle"/>
</beans>
If you want i can also post the maven pom.xml, but i think there is no error all packages are loaded and linked.
I am happy for any hint google and other pages cant help me. Here is a other example what i am trying to do : http://www.devdaily.com/blog/post/java/load-spring-application-context-file-java-swing-application
And even this post Java can't find method main did not help me
Do i have to start this application as Java Application or AspectJ/JavaApplication. Is it not possible to start a console application that way from eclipse ? Do i need to publish my files to a server ( "add to server" but this isnt working too)?
Whats confused me most is, that i see the main method :) and it is the same syntax as any hello world application.
Thanks so far...