向Jetty9部署嵌入式Jetty&Jersey战争,只能看到静态文件吗? [英] Deploy a embedded Jetty&Jersey war to jetty9,only can see static file?
问题描述
我使用IDEA和Maven创建了一个码头码头嵌入式项目,我将其放在Github中 https://github .com/Mengqi777/JettyProject .运行JettyServerStart.java启动服务器,在浏览器地址栏中输入localhost:8080/dynamic
,显示OK,输入localhost:8080/static
,显示静态资源文件
I cteate a jetty&jersey embedded project with IDEA and Maven,I put it in Github https://github.com/Mengqi777/JettyProject. Run JettyServerStart.java start the server, in the browser address bar enter localhost:8080/dynamic
, show OK, enter localhost:8080/static
, show static resource file
现在,我将其打包到一个war文件中,并将其放在jetty webapps目录中.但是只有在输入localhost:8080/dynamic
Now I package it to a war file,and put it in jetty webapps directory. But only can see static file in brower with enter localhost:8080/static
.404 Not Found Error when in brower with enter localhost:8080/dynamic
发生了什么事?
我应该怎么做才能将该项目打包到war文件或jar文件中,并在码头成功运行?
What should I do to package this project into a war file or jar file and run it in jetty successfully?
推荐答案
您正在使用JettyServerStart.java中的嵌入式码头用法来执行您未在Web应用程序或war文件中声明/配置的事情.
You are doing things in your embedded-jetty usage in JettyServerStart.java that you do not declare/configure in your webapp or war file.
这是一个Maven项目,但未声明为webapp或war项目(在pom.xml中)
It's a maven project, but not declared as a webapp or war project (in the pom.xml)
它的WEB-INF位置不正确(明智的Maven目录结构),这意味着您构建的war文件无效.
Its doesn't have its WEB-INF in the right place (maven directory structure wise), which means your built war file is invalid.
对于webapp或war项目,依赖关系未正确声明(您不能在war文件中包含jetty-server)
The dependencies are not declared correctly for a webapp or war project (you cannot include jetty-server in a war file)
您的位置不正确的WEB-INF/web.xml与您的JettyServerStart.java执行的配置步骤不同
Your badly located WEB-INF/web.xml does not perform the same configuration steps as your JettyServerStart.java
您没有指定如何创建${jetty.base}
目录以支持该war文件吗?
You don't specify how you created your ${jetty.base}
directory to support this war file?
您没有指定下载的或尝试使用的jetty-distribution
或jetty-home
版本.
You didn't specify what version of jetty-distribution
or jetty-home
you downloaded, or are attempting to work with.
不清楚将其放入jetty webapps目录中"的说法,是哪一个? (使用jetty-distribution/webapps无效,如果您尝试将其用于自己的webapps,则将导致许多错误和警告,没有jetty-home/webapps,并且您没有标识基于jetty的配置)
The statement "and put it in jetty webapps directory" is unclear, which one? (using jetty-distribution/webapps is invalid and will cause many errors and warnings if you attempt to use it for your own webapps, there's no jetty-home/webapps, and you didn't identify your jetty-base configuration)
现在就声明您的项目的方式,即使是手动组装,完全跳过maven,也没有servlet,没有过滤器,没有侦听器,没有初始化器,只有servlet规范在URL模式/
上强制使用DefaultServlet静态内容.这就是为什么访问http://localhost:8080/static/
可以正常工作的原因,但除此之外没什么.
The way your project is declared right now, even if manually assembled, skipping maven entirely, you have no servlets, no filters, no listeners, no intializers, only a servlet spec mandated DefaultServlet on url-pattern /
giving you static content. That's why accessing http://localhost:8080/static/
works, but nothing else.
这篇关于向Jetty9部署嵌入式Jetty&Jersey战争,只能看到静态文件吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!