1. 程式人生 > >Spring boot 使用Jetty作為容器

Spring boot 使用Jetty作為容器

 spring boot 預設會使用tomcat作為容器,搭建環境請檢視

https://blog.csdn.net/u011517841/article/details/77750120

 如果想使用Jetty, 按照以下內容操作

1. 先從spring boot中取出 Tomcat容器

<dependency>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-starter-web</artifactId>
	<exclusions>
		<exclusion>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-tomcat</artifactId>
		</exclusion>
	</exclusions>
</dependency>

2. 增加Jetty依賴

<dependency>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-starter-jetty</artifactId>
</dependency>

3. Run Application  專案啟動結果展示

 for JMX exposure on startup
2018-12-04 14:32:56.066  INFO 5572 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Bean with name 'dataSource' has been autodetected for JMX exposure
2018-12-04 14:32:56.069  INFO 5572 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Located MBean 'dataSource': registering with JMX server as MBean [com.alibaba.druid.pool:name=dataSource,type=DruidDataSource]
2018-12-04 14:32:56.080  INFO 5572 --- [           main] application                              : Initializing Spring FrameworkServlet 'dispatcherServlet'
2018-12-04 14:32:56.081  INFO 5572 --- [           main] o.s.web.servlet.DispatcherServlet        : FrameworkServlet 'dispatcherServlet': initialization started
2018-12-04 14:32:56.088  INFO 5572 --- [           main] o.s.web.servlet.DispatcherServlet        : FrameworkServlet 'dispatcherServlet': initialization completed in 7 ms
2018-12-04 14:32:56.144  INFO 5572 --- [           main] o.e.jetty.server.AbstractConnector       : Started 
[email protected]
{HTTP/1.1,[http/1.1]}{0.0.0.0:8080} 2018-12-04 14:32:56.146 INFO 5572 --- [ main] .s.b.c.e.j.JettyEmbeddedServletContainer : Jetty started on port(s) 8080 (http/1.1)