java web项目中集成Jetty作为web容器
来源:互联网 发布:小米手环无法同步数据 编辑:程序博客网 时间:2024/06/05 09:27
java web项目中集成Jetty作为web容器,有需要的朋友可以参考下。
1、准备好一个非常简单点的web项目(maven项目)
2、准备好maven环境,并配置pom文件,关于jetty内容如下:
<!-- jetty dependecies begin -->
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<version>9.1.4.v20140401</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-webapp</artifactId>
<version>9.1.4.v20140401</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-continuation</artifactId>
<version>9.1.4.v20140401</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-jsp</artifactId>
<version>9.1.4.v20140401</version>
</dependency>
<!-- jetty dependecies end -->
3、使用eclipse对maven项目进行build,获取build后的项目目录(或者将项目达成war包)4、创建运行配置jetty的Server类
运行war包的类
public class WebAppWarServer {
public static void main(String[] args) throws Exception {
Server server = new Server(8080);
WebAppContext context = new WebAppContext();
context.setContextPath("/myapp");
context.setWar("E:/share/test/xxx.war");
server.setHandler(context);
server.start();
server.join();
}
}
运行build后的项目目录
public class WebAppContextWithFolderServer {
public static void main(String[] args) throws Exception {
Server server = new Server(8080);
WebAppContext context = new WebAppContext();
context.setContextPath("/myapp");
context.setDescriptor("E:/share/test/struts2-blank/WEB-INF/web.xml");
context.setResourceBase("E:/share/test/struts2-blank");
context.setParentLoaderPriority(true);
server.setHandler(context);
server.start();
server.join();
}
}
0 0
- java web项目中集成Jetty作为web容器
- java web项目中集成Jetty作为web容器
- JAVA里使用Jetty作为轻量级嵌入式的Web容器
- maven 发布 web 项目(分别使用 Jetty 和 Tomcat 作为容器)
- web项目使用jetty容器启动
- eclipse集成jetty插件开发web项目
- maven集成jetty插件发布web项目
- 使用jetty作为嵌入式web容器(部署war文件)
- 使用jetty作为嵌入式web容器(部署war文件)
- Spring Boot 使用 jetty 作为默认的Web容器
- web容器之jetty
- 在java web项目中集成webservice
- 在java web项目中集成webservice
- 图文详解 IntelliJ IDEA 15 创建 Maven 构建的 Java Web 项目(使用 Jetty 容器)
- Eclipse中使用jetty启动Web项目
- Java项目嵌入Jetty-Web服务器
- 利用Jetty部署Java web项目
- eclipse集成jetty开发maven web项目(超简单)
- ThreadLocal初识
- STM32 CAN 总线 自我学习总结
- 照片尺寸对照单Microsoft Word 文档
- 第三话-单一职责原则
- 如何生成二维码代码详解
- java web项目中集成Jetty作为web容器
- java基于mahout内存应用关联规则推荐算法fpgrowth
- android自定义圆环控件 滑动选择百分比
- 遍历map
- AFNetworking2.0源码解析<二>
- layoutSubviews总结
- Linux解决问题篇——ftp上传文件(使用put)时,permission denied,下载文件(使用get)时,failed to open file
- <link>标签的rel属性详解
- Redis安装 For CentOS6.4_64