0

我想使用 moo 进行 dto- 实体转换。但是测试它我得到了这个异常

    Exception in thread "main" java.lang.NoClassDefFoundError: org/mvel2/PropertyAccessException
    at com.codiform.moo.configuration.Configuration.getTranslator(Configuration.java:62)
    at com.codiform.moo.session.TranslationSession.getTranslator(TranslationSession.java:131)
    at com.codiform.moo.session.TranslationSession.translate(TranslationSession.java:122)
    at com.codiform.moo.session.TranslationSession.getTranslation(TranslationSession.java:64)
    at com.codiform.moo.curry.Translate.from(Translate.java:63)
    at Main.main(Main.java:15)
Caused by: java.lang.ClassNotFoundException: org.mvel2.PropertyAccessException
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
    ... 6 more

是因为我做错了什么吗?这是我的代码:

import com.codiform.moo.curry.Translate;


public class Main {

    /**
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub
Guld guld1=new Guld("string from guld", "muck around", 5);
GuldDTO guld1DTO;
GuldDTO testclassload = new GuldDTO("ruks","halim",3);

guld1DTO=Translate.to(GuldDTO.class).from(guld1);
        //Beca beca1 = new Beca ()

System.out.println(guld1);
System.out.println(guld1DTO);
    }

}

public class Guld {

    private String fielk1;
    private String rupo;
    private Integer higs;
    public Guld(){

    }
    public Guld(String fielk1, String rupo, Integer higs) {

        this.fielk1 = fielk1;
        this.rupo = rupo;
        this.higs = higs;
    }
    public String getFielk1() {
        return fielk1;
    }
    public void setFielk1(String fielk1) {
        this.fielk1 = fielk1;
    }
    public String getRupo() {
        return rupo;
    }
    public void setRupo(String rupo) {
        this.rupo = rupo;
    }
    public Integer getHigs() {
        return higs;
    }
    public void setHigs(Integer higs) {
        this.higs = higs;
    }


}

public class GuldDTO {
    private String fielk1;
    private String rupo;
    private Integer higs;
    public GuldDTO (){

    }
    public GuldDTO(String fielk1, String rupo, Integer higs) {

        this.fielk1 = fielk1;
        this.rupo = rupo;
        this.higs = higs;
    }
    public String getFielk1() {
        return fielk1;
    }
    public void setFielk1(String fielk1) {
        this.fielk1 = fielk1;
    }
    public String getRupo() {
        return rupo;
    }
    public void setRupo(String rupo) {
        this.rupo = rupo;
    }
    public Integer getHigs() {
        return higs;
    }
    public void setHigs(Integer higs) {
        this.higs = higs;
    }

}

如果有任何其他细节我应该提供,请告诉。[显然我无法通过检查代码与文本比率的stackoverflow过滤器。] [完成]

4

3 回答 3

2

ClassNotFoundException excption 表示该类缺少该类的添加库并再次运行。首先检查您的应用程序是否具有此类或不添加 mvel lib。

可在: http: //grepcode.com/snapshot/repo1.maven.org/maven2/org.mvel/mvel2/2.1.4.Final/

于 2013-07-08T03:49:54.620 回答
0

java.lang.NoClassDefFoundError当您对该类有依赖项并且它不在项目的依赖项列表中时,您会看到。

所以,你需要做的是:

org.mvel2.PropertyAccessException在外部将类的 jar 添加到您的项目中

该罐子可在此处获得。

于 2013-07-08T03:55:48.130 回答
0

正如上面其他人已经说过的,您缺少一个类文件,您需要在classpath. 为了检查类的加载方式和位置,您可以传递-verbose:classjavaexe。这将显示程序运行时加载的类的跟踪。对于调试此类问题很有用。

于 2013-07-08T03:59:53.663 回答