我有一个基于JBoss的EclipseAs7和Eclipse项目名为露娜的项目。我使用的是带注释的servlet,并且有一个非常简单的JPA实体和DAO。
当我通过Eclipse部署时,servlet不会启动。
如果我通过JBOss web接口进行mvn package和部署,则会部署servlet。
使用eclipse时,将部署JPA类并设置持久化内容,但我没有从servlet获得任何内容。
除了persistence.xml之外,我没有任何XML文件,只有带注释的servlet,如下所示:
@WebServlet(urlPatterns = {"/simple"}, loadOnStartup=1)
public class EntityServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
@EJB EntityDao ed;
public EntityServlet() {
System.err.println("Starting servlet");
System.err.println("ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ");
}
public void setEntityDao(EntityDao e){
ed = e;
}
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out=response.getWriter();
out.print("<html><body>");
out.print("<h3>Hello Servlet</h3><p>");
out.print(ed.addNamedEntity("ADSF"));
out.print("</p>");
out.print("<p>" + ed.getAllNamedEntities() + "</p></body></html>");
}
}发布于 2015-07-15 02:01:40
天啊,找到问题所在了。
我注意到我的测试用例没有编译,所以我开始追查它,发现我的.project文件中的java构建器已经不在了(不知道它去了哪里)。
Here is the link to the fix for the compile problems
它的要点是你必须添加:
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>如果确实缺少.project文件,请将其添加到buildSpec部分中。
https://stackoverflow.com/questions/31407668
复制相似问题