2013年12月15日星期日

Running spring problem


package cn.csdn.hr.service;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class Test {

/**
 * @param args
 */
public static void main(String[] args) {
// TODO Auto-generated method stub
ApplicationContext context=new ClassPathXmlApplicationContext("applicationContext.xml");
 
        //获取BeanFactory工厂创建的bean对象 得到一个bean实例对象 
        GreetingService greetingService = (GreetingService) context.getBean("geetingServiceBean"); 

        greetingService.sayGeeting(); 

}

}

I applicationContext.xml together in a bag , running has been reported
Exception in thread "main" java.lang.NoClassDefFoundError: org / apache / commons / logging / LogFactory
------ Solution ------- -------------------------------------
this is the log4j jar did not import it
------ Solution ------------------------------------------ -
what you have imported the jar, cut a figure out
------ Solution ------------------------ --------------------
visual application.xml file can not be found , if you look at the path is wrong !
------ Solution ---------------------------------------- ----
file path written wrong. If you want to write down the default classpath , then you need to put under application.xml src directory. If you put up a package under src , then you need to add the package name. For example : com.application.xml or com / application.xml Or classpath: com / application.xml. Forget what the rules are , but nothing more than these three , you try
------ Solution ----------------------- ---------------------
I rub , I warned you tell where ? All the ' information ' , okay? Red is not necessarily a warning !
------ For reference only -------------------------------------- -
looks like not find applicationContext.xml
------ For reference only ------------------------- --------------
I downloaded the jar that the bag did not log4
I did not have a jar found in the official website to download the package had in other places under
------ For reference only ---------------- -----------------------
I downloaded log4
http://111.13.109.58:81/1Q2W3E4R5T6Y7U8I9O0P1Z2X3C4V5B/www.apache.org/dyn/closer.cgi/logging/log4j/1.2.17/log4j-1.2.17.tar.gz
import in, or reported this wrong , ask God to help large
------ For reference only ---------------------- -----------------
or spring months to be able to run up the example will do
------ For reference only ------ ---------------------------------
it seems to lead back to the right , and now files are not reported exist

------ For reference only ----- ----------------------------------



------ For reference only ----- ----------------------------------
ah put src inside , it looks a step closer However, there is still a problem


------ For reference only ----- ----------------------------------
landlord, your jar pack a big change .
This package aopalliance.jar also needed, you can look for spring required jar package
------ For reference only online -------------- -------------------------
ah , which are turned back to go , but why are the red warning

------ For reference only ----- ----------------------------------
Oh , beginner , beginner , laughed , laughed

没有评论:

发表评论