spring 3.0 部署

今天简单的部署了一下 spring3.0 ,但是尽让报错,但还使用系统的类在 spring2.5.6中就可以运行。

下面是我的错误信息
2010-1-17 1:57:04 org.springframework.context.support.AbstractApplicationContext prepareRefresh
信息: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@1632c2d: startup date [Sun Jan 17 01:57:04 CST 2010]; root of context hierarchy
Exception in thread "main" java.lang.ExceptionInInitializerError
at org.springframework.context.support.AbstractRefreshableApplicationContext.createBeanFactory(AbstractRefreshableApplicationContext.java:194)
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:127)
at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:458)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:388)
at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:83)
at com.chj.test.Test.main(Test.java:13)
Caused by: java.lang.NullPointerException
at org.springframework.beans.factory.support.DefaultListableBeanFactory.(DefaultListableBeanFactory.java:103)
... 7 more

下面是我的java main

package com.chj.test;

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

public class Test {

/**
 * @param args
 */
public static void main(String[] args) {
    ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
    User  user  = (User) context.getBean("user");
} 

}

下面是我导入的jar
org.springframework.core-3.0.0.RELEASE.jar
org.springframework.context-3.0.0.RELEASE.jar
org.springframework.beans-3.0.0.RELEASE.jar

会不会把spring3.0的包和spring2.5的包混合在一起了啊?造成包冲突啊。

另外一个就是:检查你的applicationContext.xml,因为spring的版本变更,完全有可能导致applicationContext.xml文件在spring3中解析错误。

因为在你的异常中有一个是涉及到静态变量的问题,在你的代码中也就只有applicationContext.xml可能会有问题。

先把所有包都导入试试呢?
这个例子太简单,肯定不是程序的问题

配置文件是不是找不到

检查一下classes目录下面有没有applicationContext.xml文件。
如果有的话,你用下面的方法看看:

ApplicationContext ctx=new FileSystemXmlApplicationContext("src/applicationContext.xml");

如果没有的话,就是你编译有问题,然后把applicationContext.xml copy到classes下面,在运行一下。
如果都不可以,你把有问题的工程打个包放上来,大家帮你弄弄,毕竟现在的情况都是在猜测嘛,