For Classpathxmlapplicationcontext (), classpath: prefix is not required, default refers to the project classpath path below;
If you want to use an absolute path, you need to add a file: prefix to indicate that this is an absolute path;
For Filesystemxmlapplicationcontext (), the default representation is two types:
1, no drive letter is the project work path, that is, the root directory of the project;
2, a drive letter represents the absolute path of the file.
If you want to use the classpath path, prefix classpath is required:
public class Helloclient {protected static final log log = Logfactory.getlog (Helloclient.class);
public static void Main (string[] args) {//Resource Resource = new Classpathresource ("Appcontext.xml");
Beanfactory factory = new Xmlbeanfactory (Resource);
With Classpath path can also//ApplicationContext factory=new classpathxmlapplicationcontext ("Classpath:appcontext.xml");
ApplicationContext factory=new classpathxmlapplicationcontext ("Appcontext.xml"); ApplicationContext factory=new classpathxmlapplicationcontext ("File:g:/1java Utility Project resource/2SPRING/1 proficient in spring full jar code/
Workspace/workspace/example6/src/appcontext.xml ");
Using the file system path//ApplicationContext factory=new filesystemxmlapplicationcontext ("Src/appcontext.xml"); Use the classpath: prefix as a flag, so that Filesystemxmlapplicationcontext can also read the relative path under classpath//ApplicationContext Factory
=new filesystemxmlapplicationcontext ("Classpath:appcontext.xml"); ApplicationContext FactoRy=new filesystemxmlapplicationcontext ("File:g:/1java Utility Project resource/2SPRING/1 proficient in spring full jar code/workspace/workspace/
Example6/src/appcontext.xml "); ApplicationContext factory=new filesystemxmlapplicationcontext ("G:/1java Utility Project resource/2SPRING/1 proficient in spring full jar code/workspace
/workspace/example6/src/appcontext.xml ");
Ihelloworld HW = (ihelloworld) factory.getbean ("Helloworldbean");
Log.info (Hw.getcontent ("Luoshifei")); }
}