嗨,我正在使用 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' />