Class path resource [Applicationcontext.xml]; Nested exception is JAVA.IO.FILENOTFOUNDEXCEPTION:CLA

Source: Internet
Author: User
Tags log4j

CH10. Development and application of Spring framework

Package src.com.qdu.sun.Spring;

Import Org.springframework.beans.factory.BeanFactory;
Import Org.springframework.beans.factory.xml.XmlBeanFactory;
Import Org.springframework.core.io.ClassPathResource;

public class Springtest {
public static void Main (string[] args) {
Beanfactory factory = new Xmlbeanfactory (New Classpathresource ("Applicationcontext.xml"));
HelloWorld GC = (HelloWorld) factory.getbean ("Greetingservice");
Gc.saygreeting ();
}
}

Log4j:warn No Appenders could is found for logger (org.springframework.util.ClassUtils).
Log4j:warn Please initialize the log4j system properly.
Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException:IOException parsing XML Document from

Class path resource [Applicationcontext.xml]; Nested exception is Java.io.FileNotFoundException:class path resource

[Applicationcontext.xml] cannot is opened because it does not exist
caused By:java.io.FileNotFoundException:class path resource [Applicationcontext.xml] cannot be opened because it does no T exist
At Org.springframework.core.io.ClassPathResource.getInputStream (classpathresource.java:135)
At Org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions ( xmlbeandefinitionreader.java:297)
At Org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions ( xmlbeandefinitionreader.java:280)
At Org.springframework.beans.factory.xml.xmlbeanfactory.<init> (xmlbeanfactory.java:73)
At Org.springframework.beans.factory.xml.xmlbeanfactory.<init> (xmlbeanfactory.java:61)
At Src.com.qdu.sun.Spring.SpringTest.main (springtest.java:9)

Modified to:

public class Springtest {
public static void Main (string[] args) {
Beanfactory factory = new Xmlbeanfactory (New Classpathresource ("Src/applicationcontext.xml"));

Output:

Log4j:warn No Appenders could is found for logger (org.springframework.util.ClassUtils).
Log4j:warn Please initialize the log4j system properly.
You yi ge Greeting

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.