本文基于前一篇文章为基础进行改进,需要了解前篇内容的请访问
这里
1、pom.xml中添加nano-server依赖
1.1、依赖
<dependency>
<groupId>org.nanoframework</groupId>
<artifactId>nano-server</artifactId>
<version>1.2.0-RC1</version>
<exclusions>
<exclusion>
<groupId>org.glassfish.web</groupId>
<artifactId>javax.el</artifactId>
</exclusion>
<exclusion>
<groupId>org.glassfish.web</groupId>
<artifactId>javax.servlet.jsp</artifactId>
</exclusion>
<exclusion>
<groupId>org.eclipse.jetty.orbit</groupId>
<artifactId>javax.servlet</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.glassfish.web</groupId>
<artifactId>javax.el</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.glassfish.web</groupId>
<artifactId>javax.servlet.jsp</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>javax.servlet.jsp-api</artifactId>
<scope>provided</scope>
</dependency>
1.2、resources
<build>
...
<resources>
...
<resource>
<directory>src/main/webapp</directory>
<targetPath>${project.basedir}/webRoot/</targetPath>
</resource>
...
</resources>
...
</build>
2、在WEB-INF下添加jetty.xml和webdefault.xml
2.1、jetty.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
<Configure id="Server" class="org.eclipse.jetty.server.Server">
<Set name="ThreadPool">
<!-- Default queued blocking threadpool -->
<New class="org.eclipse.jetty.util.thread.QueuedThreadPool">
<Set name="minThreads">5</Set>
<Set name="maxThreads">200</Set>
<Set name="detailedDump">false</Set>
</New>
</Set>
<Call name="addConnector">
<Arg>
<New class="org.eclipse.jetty.server.nio.SelectChannelConnector">
<Set name="host">
<Property name="jetty.host" />
</Set>
<Set name="port">
<Property name="jetty.port" default="8081" />
</Set>
<Set name="maxIdleTime">300000</Set>
<Set name="Acceptors">2</Set>
<Set name="statsOn">false</Set>
<Set name="confidentialPort">8443</Set>
<Set name="lowResourcesConnections">20000</Set>
<Set name="lowResourcesMaxIdleTime">5000</Set>
</New>
</Arg>
</Call>
</Configure>
2.2、webdefault.xml
因篇幅过长不在这里列出,请访问
原文中的2.2配置
3、在org.nanoframework.examples.first.webapp下添加启动器
import org.nanoframework.server.JettyCustomServer;
public class Startup {
public static void main(String[] args) {
JettyCustomServer server = JettyCustomServer.DEFAULT;
new Thread(() -> { server.startServer(); }).start();
}
}
4、至此集成内嵌Jetty完成,运行Startup并访问http://ip:port/first-webapp/first/hello
分享到:
相关推荐
jetty容器内嵌到java代码中,通过代码控制启动,方便开发调试
jetty内嵌实现,手动启动 WEB服务,不用发布到服务器上就可以访问。
jetty服务器内嵌实例,运行JettTest后即可访问
由于以前写了个jetty内嵌的服务器,需要在其上面添加JSF的东西 试了好久,终于调通了,拿出来给大家分享一下 本demo是使用jetty内嵌的方式发布的jsf的demo 整个demo是工程整个打包,包含所有的jar包,包括使用的...
Jetty配置支持HTTPS以及受信网站证书生成方式
NULL 博文链接:https://fuaotech.iteye.com/blog/2292707
jetty实例,嵌入式jetty,java接收json数据,取特定字符,展示到浏览器,
NULL 博文链接:https://qindongliang.iteye.com/blog/2090085
代码纯原创,通过本demo,可以轻松实现在应用程序中,利用Jetty去监听某个HTTP请求端口或者服务。 例如让本地应用程序不依赖于任何的Server,就能提供本地化的请求服务localhost:8080/omi/event.
jetty-security-9.4.8.v20171121.jar,jetty-io-9.4.8.v20171121.jar,jetty-continuation-9.4.8.v20171121.jar,jetty-client-9.4.8.v20171121.jar,jetty-jmx-9.4.8.v20171121.jar,jetty-plus-9.4.8.v20171121....
内嵌Jetty的HelloWorld教程 内嵌Jetty视频 优化Jetty 如何配置垃圾收集 如何配置以支持高负载 在Jetty中部署应用 部署管理器 部署绑定 热部署 Context提供者 如何部署web应用 webApp提供者 如何部署第三方产品 部署...
NULL 博文链接:https://xiaoyongzeng.iteye.com/blog/1930361
启动jetty的start.jar,此文件所在目录下增加lib,etc,context文件夹,lib下增加jetty的主jar包和jetty的util包。在etc下增加jetty的两个配置文件jetty.xml和webdefault.xml。在context下增加test.xml
eclipse jetty插件,从...下载run-jetty-run.zip文件,解压后再编写个links文件丢到eclipse的dropins目录下即可,省去了使用eclipse update方式安装的麻烦。 link文件样例如: path=d:\\eclipse_plugins\\run-jetty-run
Jetty软件包内容: jetty-distribution-9.4.51.v20230217.tar.gz jetty-distribution-9.4.51.v20230217.zip jetty-home-10.0.15.tar.gz jetty-home-10.0.15.zip jetty-home-11.0.15.tar.gz jetty-home-11.0.15.zip ...
jetty 是一款轻量级的web服务器,相比Tomcat版本更复杂,每个jdk的版本使用的jetty都可能不一样,9.4的版本适合jdk1.8使用
jetty是什么 jetty配置 jetty使用 jetty嵌入 jetty启动 jetty部署 jetty教程 jetty嵌入式 jetty
比run-jetty-run启动要快,但是调试没有run-jetty-run方便。 eclipse插件 离线安装包 Eclipse中Install New Software 然后Add -> Archive,选择该包安装即可 ...支持Jetty7, Jetty8, jetty9, Servlet3
Jetty 7是Jetty奔向Eclipse后发布的第一个版本,本次的Jetty 7 RC2带给了我们一个十分诱人的新特性-支持跨域名Ajax请求。众所周知因为安全的原因,多数浏览器都限制了Ajax跨域请求和javascript加载的时候只能是与...
jetty-6.1.14包,应用程序内嵌服务器包