用eclipse EE重新部署动态网络项目到野生蝇服务器
我正在使用Eclipse EE创建一个动态的Web项目,以在Wildfly V18服务器上运行。我只是为了确保我的设置工作并在Web.xml文件中映射并映射到一个测试servlet:
@WebServlet("/Test")
public class Test extends HttpServlet {
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
// TODO Auto-generated method stub
response.getWriter().append("<h1>Test</h1>");
}
}
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd" id="WebApp_ID" version="4.0">
<servlet>
<servlet-name>test</servlet-name>
<servlet-class>com.nhbb.test.Test</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>test</servlet-name>
<url-pattern>/test</url-pattern>
</servlet-mapping>
</web-app>
servlet可以正常工作,当我打开localhost:8080/testProject/test
in我的网络浏览器。但是,如果我更改Servlet响应中的文本,则更改不会反映在服务器或前端。
我尝试重新启动服务器,将项目从服务器中删除并重新部署它,将服务器设置更改为“在构建事件发生后自动发布”,启用Hot Code用Regex Pattern \。jar $ | \ .class $替换。
,甚至重新启动我的计算机。在每种情况下,除非删除项目并通过所需的更改从头开始重新创建它,否则这些更改均不会反映在服务器或前端。
我发现了另一个解决方法,其中涉及关闭服务器,将项目从eclipse导出为战争文件,删除服务器的standalone \ exployments \/code>目录的内容,然后将战争文件的内容提取到相同的内容在再次打开服务器之前,目录。这种方法有效,但非常不便和不切实际。
我相信我的设置有问题,因为重新部署应该比这容易得多。同时,我使用默认设置创建了动态Web项目,因此我看不出它是如何工作的。
我如何实际将项目重新部署到服务器?
I am creating a dynamic web project using Eclipse EE to run on a Wildfly v18 server. I setup a test servlet just to ensure that my setup is working and mapped it in the web.xml file:
@WebServlet("/Test")
public class Test extends HttpServlet {
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
// TODO Auto-generated method stub
response.getWriter().append("<h1>Test</h1>");
}
}
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd" id="WebApp_ID" version="4.0">
<servlet>
<servlet-name>test</servlet-name>
<servlet-class>com.nhbb.test.Test</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>test</servlet-name>
<url-pattern>/test</url-pattern>
</servlet-mapping>
</web-app>
The servlet works and I get the desired results when I open localhost:8080/TestProject/test
in my web browser. However, if I change the text in the servlet response, the changes are not reflected on the server or the front end.
I tried restarting the server, removing the project from the server and redeploying it, changing the server settings to "Automatically publish after a build event," enabling hot code replacement with the regex pattern \.jar$|\.class$
, and even restarting my computer. In every case, the changes are not reflected on the server or the front end unless delete the project and recreate it from scratch with the desired changes.
I discovered another workaround which involved shutting down the server, exporting the project from Eclipse as a WAR file, deleting the contents of the server's standalone\deployments
directory, then extracting the contents of the WAR file to the same directory before turning the server back on again. This approach works but is highly inconvenient and impractical.
I believe there is something wrong with my setup because redeployment should be much easier than this. At the same time, I created the dynamic web project using the default settings, so I cannot see how it does not work.
How can I practically redeploy my project to the server?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
“在构建事件后自动发布”意味着您 build ,即自动构建,以部署更新的类文件。这也不是针对野生蝇服务器的。
"Automatically publish after a build event" implies that you build, i.e. leave automatic builds on, to deploy updated class files. This is also not specific to WildFly servers.