I'm having some difficulties with the simplest maven-w760 application. In fact, it BeanFactorydoes not find the file appContext.xml, despite the fact that it is in the resource directory and correctly copied to the target directory. Here is my main class, dir structure and error:
package sas.test.spring;
import java.io.FileInputStream;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.core.io.Resource;
public class App {
public static void main(String[] args) throws Exception {
System.out.println("Hello World!");
BeanFactory fact = new XmlBeanFactory((Resource) new FileInputStream("appContext.xml"));
GreetingService gs = (GreetingService) fact.getBean("greetingService");
gs.sayGreeting();
}
}
Directory structure after mvn compile:
testspring002
|
| `
| |
| | `
| | `
| | `
| | |
| | |
| | `
| `
| `
...
`
`
|
`
`
`
|
|
`
And here is the error:
/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home/bin/java -Dclassworlds.conf=/usr/share/java/maven-2.2.0/bin/m2.conf -Dmaven.home=/usr/share/java/maven-2.2.0 -Dfile.encoding=MacRoman -classpath /usr/share/java/maven-2.2.0/boot/classworlds-1.1.jar org.codehaus.classworlds.Launcher
+ Enabling strict checksum verification on all artifact downloads.
[INFO] Scanning for projects...
[INFO]
[INFO] Building testspring002
[INFO] task-segment: [org.codehaus.mojo:exec-maven-plugin:1.1.1:java]
[INFO]
[INFO] Preparing exec:java
[INFO] artifact org.codehaus.mojo:exec-maven-plugin: checking for updates from central
[INFO] No goals needed for project - skipping
[INFO] [exec:java {execution: default-cli}]
Hello World!
[INFO]
[ERROR] BUILD ERROR
[INFO]
[INFO] An exception occured while executing the Java class. null
appContext.xml (No such file or directory)
Any suggestions?
source
share