使用ClassPathXmlApplicationContext加载bean

时间:2014-06-23 11:08:44

标签: spring

这是我的界面

public interface PersonneService {
    public void add(Personne personne);
    public void delete (int PersonneID);
    public Personne getPersonne(int PersonneID); 
    public List getAllPersonne();
}

这是我班主要的

import static org.junit.Assert.*;
import java.util.List;

import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;

import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.test.model.Personne;

public class PersonneServiceTest {
 private static ClassPathXmlApplicationContext context;
 private static PersonneService personneService;

    @BeforeClass
    public static void setUpBeforeClass() throws Exception {
        context= new ClassPathXmlApplicationContext("ApplicationContext.xml");
        personneService=(PersonneService) context.getBean("PersonneService");
    }

    @AfterClass
    public static void tearDownAfterClass() throws Exception {
        context.close();
    }

这是错误

    org.springframework.context.support.AbstractApplicationContext prepareRefresh
INFOS: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@1b10f9a: display name [org.springframework.context.support.ClassPathXmlApplicationContext@1b10f9a]; startup date [Mon Jun 23 11:03:13 WEST 2014]; root of context hierarchy
juin 23, 2014 11:03:13 AM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFOS: Loading XML bean definitions from class path resource [ApplicationContext.xml]
juin 23, 2014 11:03:14 AM org.springframework.context.support.AbstractApplicationContext obtainFreshBeanFactory
INFOS: Bean factory for application context [org.springframework.context.support.ClassPathXmlApplicationContext@1b10f9a]: org.springframework.beans.factory.support.DefaultListableBeanFactory@648a34

在Spring中进行示例项目时出现了一些错误。我的application-context.xml在src中,但不起作用:

java.lang.NoClassDefFoundError: org/antlr/runtime/RecognitionException

0 个答案:

没有答案