1

嗨,我正在使用 GWT eclipselink 和 hsqldp 开展一个项目,但我得到了这个:

[ERROR] [myproject]: No source code is available for type it.myproject.server.CreateEmployee; did you forget to inherit a required module?

似乎 eclipse gwt 找不到我的班级 CreateEmployee 甚至认为我输入了正确的导入..!这是代码(CreateEmployee.java):

package it.myproject.server;
 import it.myproject.shared.entity.Employee;
 import javax.persistence.EntityManager;
 import javax.persistence.EntityManagerFactory;
 import javax.persistence.Persistence;


public class CreateEmployee {
  public static void createNewEmployee() {

    EntityManagerFactory emf = Persistence.createEntityManagerFactory("ronfPU");
    EntityManager em = emf.createEntityManager();

    try {
        Employee e1= new Employee();
        e1.setUsername("admin");
        e1.setPassword("admin");
        em.persist(e1);
        em.getTransaction().commit();
    } finally {
        em.close();
    }
  }
 }

这是 myproject.java 的主文件:

package it.myproject.client;
import it.myproject.server.CreateEmployee;
import it.myproject.shared.entity.Employee;
import com.google.gwt.core.client.EntryPoint;
public class myproject implements EntryPoint {
  @Override
  public void onModuleLoad() {

    try{
        new CreateEmployee();
        CreateEmployee.createNewEmployee();

    } catch (Exception e) {
        Window.alert("creation of employees failed");
    }
 [....here 's some others useless codes..]
}

这些是我的源路径(myproject.gwt.xml):

<!-- Specify the paths for translatable code -->
 <source path='client' />
 <source path='shared' />
4

1 回答 1

1
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

不是客户端 gwt 标准库的一部分。您必须删除它,否则您必须继承 gwt-project 中的库(但我认为没有这样的库)。您CreateEmployee的课程应该是纯服务器逻辑,而不是客户端。

于 2013-07-10T09:22:02.710 回答