java.lang.LinkageError: JAXB 2.0 API is being loaded from the bootstrap classloa

重装系统后原来项目中的单元测试跑不了,报错Caused by: java.lang.LinkageError: JAXB 2.0 API is being loaded from the bootstrap classloader, but this RI (from jar:file:/D:/workspace/ecif_svn/WebContent/WEB-INF/lib/jaxb-impl-2.1.12.jar!/com/sun/xml/bind/v2/model/impl/ModelBuilder.class) needs 2.1 API. Use the endorsed directory mechanism to place jaxb-api.jar in the bootstrap classloader. (See http://java.sun.com/j2se/1.5.0/docs/guide/standards/)

解决办法:
    在项目中任意类中写个main 方法,然后打印:
System.out.println(System.getProperty("java.endorsed.dirs"));
我的是C:\Program Files\Java\jre1.6.0\lib\endorsed,找到这个目录,如果没有自己创建,然后把jaxb-api-2.1.jar,jaxb-impl-2.1.12.jar放到这里面就好使了.

你可能感兴趣的:(java,单元测试)