Maven JVM服务器端口选项

Maven JVM服务器端口选项,maven,jvm,spring-boot,Maven,Jvm,Spring Boot,jvm选项-Dserver.port=-1是什么意思?我知道将其设置为0意味着随机端口。有一篇很好的文章。它的意思是“创建一个WebApplicationContext,但不要启动服务器”。让我们看一下从同一个使用不同选项运行的测试spring应用程序中截取的两个屏幕截图 C:\>java -jar -Dserver.contextPath=/testapp -Dserver.port=0 spring-security-test-0.0.1-SNAPSHOT.jar . ____

jvm选项
-Dserver.port=-1
是什么意思?我知道将其设置为0意味着随机端口。有一篇很好的文章。

它的意思是“创建一个WebApplicationContext,但不要启动服务器”。

让我们看一下从同一个使用不同选项运行的测试spring应用程序中截取的两个屏幕截图

C:\>java -jar -Dserver.contextPath=/testapp -Dserver.port=0 spring-security-test-0.0.1-SNAPSHOT.jar . ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v1.0.2.RELEASE) 2014-05-29 10:22:36.434 INFO 10172 --- [ main] s.t.spring.security.config.Application : Starting Application on KOLTM28902K0NX with PID 10172 (C:\spring-security-test- 0.0.1-SNAPSHOT.jar started by 607130889 in C:\) 2014-05-29 10:22:36.481 INFO 10172 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWe bApplicationContext@1d256fa: startup date [Thu May 29 10:22:36 IST 2014]; root of context hierarchy 2014-05-29 10:22:37.619 INFO 10172 --- [ main] .t.TomcatEmbeddedServletContainerFactory : Server initialized with port: 0 2014-05-29 10:22:37.744 INFO 10172 --- [ main] o.apache.catalina.core.StandardService : Starting service Tomcat 2014-05-29 10:22:37.744 INFO 10172 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/7.0.52 2014-05-29 10:22:37.853 INFO 10172 --- [ost-startStop-1] o.a.c.c.C.[.[localhost].[/testapp] : Initializing Spring embedded WebApplicationContext 2014-05-29 10:22:37.853 INFO 10172 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1372 ms 2014-05-29 10:22:38.805 INFO 10172 --- [ost-startStop-1] o.s.s.web.DefaultSecurityFilterChain : Creating filter chain: org.springframework.security.web.util.matcher.AnyRequest Matcher@1, [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@a30fd, org.springframework.security.web.context.SecurityContextPersistenceFilter @cad437, org.springframework.security.web.header.HeaderWriterFilter@1f18cbe, org.springframework.security.web.csrf.CsrfFilter@725967, org.springframework.security.web.authenticatio n.logout.LogoutFilter@1ed688f, org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter@10ff62a, org.springframework.security.web.savedrequest.RequestCa cheAwareFilter@f18d37, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@1c0b8a0, org.springframework.security.web.authentication.AnonymousAuthent icationFilter@11650d6, org.springframework.security.web.session.SessionManagementFilter@178c490, org.springframework.security.web.access.ExceptionTranslationFilter@1de7497, org.spr ingframework.security.web.access.intercept.FilterSecurityInterceptor@4d28c7] 2014-05-29 10:22:38.867 INFO 10172 --- [ost-startStop-1] o.s.b.c.e.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/] 2014-05-29 10:22:38.867 INFO 10172 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'springSecurityFilterChain' to: [/*] 2014-05-29 10:22:38.867 INFO 10172 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*] 2014-05-29 10:22:39.148 INFO 10172 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframewo rk.web.servlet.resource.ResourceHttpRequestHandler] 2014-05-29 10:22:39.211 INFO 10172 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/hello] onto handler of type [class org.springframework.web.se rvlet.mvc.ParameterizableViewController] 2014-05-29 10:22:39.211 INFO 10172 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/home] onto handler of type [class org.springframework.web.ser vlet.mvc.ParameterizableViewController] 2014-05-29 10:22:39.211 INFO 10172 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/login] onto handler of type [class org.springframework.web.se rvlet.mvc.ParameterizableViewController] 2014-05-29 10:22:39.211 INFO 10172 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Root mapping to handler of type [class org.springframework.web.servlet.mvc.Para meterizableViewController] 2014-05-29 10:22:39.273 INFO 10172 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.springframework.web.servl et.resource.ResourceHttpRequestHandler] 2014-05-29 10:22:39.273 INFO 10172 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.w eb.servlet.resource.ResourceHttpRequestHandler] 2014-05-29 10:22:39.585 INFO 10172 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup 2014-05-29 10:22:39.663 INFO 10172 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 56822/http 2014-05-29 10:22:39.663 INFO 10172 --- [ main] s.t.spring.security.config.Application : Started Application in 3.666 seconds (JVM running for 4.056)
在这里,当应用程序使用
server.port=-1
option运行时,服务器启动通知丢失。

谢谢Dave!如果我们使用的是嵌入式服务器,比如任何spring boot应用程序,你能评论一下这个选项会产生什么影响吗?这就是我的意思(嵌入式服务器没有启动)。是的,我理解。我关心的是,这个选项对于嵌入式服务器来说是如何相关的。 . ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v1.0.2.RELEASE) 2014-05-29 09:59:31.815 INFO 2756 --- [ main] s.t.spring.security.config.Application : Starting Application on KOLTM28902K0NX with PID 2756 (C:\Users\607130889\Share\s pring-security-test-0.0.1-SNAPSHOT.jar started by 607130889 in C:\Users\607130889\Share) 2014-05-29 09:59:31.908 INFO 2756 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWeb ApplicationContext@1c5f743: startup date [Thu May 29 09:59:31 IST 2014]; root of context hierarchy 2014-05-29 09:59:34.295 INFO 2756 --- [ main] .t.TomcatEmbeddedServletContainerFactory : Server initialized with port: -1 2014-05-29 09:59:34.748 INFO 2756 --- [ main] o.apache.catalina.core.StandardService : Starting service Tomcat 2014-05-29 09:59:34.748 INFO 2756 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/7.0.52 2014-05-29 09:59:35.013 INFO 2756 --- [ost-startStop-1] o.a.c.c.C.[.[localhost].[/secure] : Initializing Spring embedded WebApplicationContext 2014-05-29 09:59:35.013 INFO 2756 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 3105 ms 2014-05-29 09:59:36.526 INFO 2756 --- [ost-startStop-1] o.s.s.web.DefaultSecurityFilterChain : Creating filter chain: org.springframework.security.web.util.matcher.AnyRequestM atcher@1, [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@167c6fd, org.springframework.security.web.context.SecurityContextPersistenceFilte r@139d115, org.springframework.security.web.header.HeaderWriterFilter@19d9c0d, org.springframework.security.web.csrf.CsrfFilter@1384ed5, org.springframework.security.web.authentica tion.logout.LogoutFilter@14189d0, org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter@2cd728, org.springframework.security.web.savedrequest.Request CacheAwareFilter@83de21, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@1b2380e, org.springframework.security.web.authentication.AnonymousAuthe nticationFilter@39452f, org.springframework.security.web.session.SessionManagementFilter@154c054, org.springframework.security.web.access.ExceptionTranslationFilter@5db9eb, org.springframework.security.web.access.intercept.FilterSecurityInterceptor@1353154] 2014-05-29 09:59:36.589 INFO 2756 --- [ost-startStop-1] o.s.b.c.e.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/] 2014-05-29 09:59:36.604 INFO 2756 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'springSecurityFilterChain' to: [/*] 2014-05-29 09:59:36.604 INFO 2756 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*] 2014-05-29 09:59:37.213 INFO 2756 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframewor k.web.servlet.resource.ResourceHttpRequestHandler] 2014-05-29 09:59:37.415 INFO 2756 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/hello] onto handler of type [class org.springframework.web.ser vlet.mvc.ParameterizableViewController] 2014-05-29 09:59:37.415 INFO 2756 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/home] onto handler of type [class org.springframework.web.serv let.mvc.ParameterizableViewController] 2014-05-29 09:59:37.415 INFO 2756 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/login] onto handler of type [class org.springframework.web.ser vlet.mvc.ParameterizableViewController] 2014-05-29 09:59:37.415 INFO 2756 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Root mapping to handler of type [class org.springframework.web.servlet.mvc.Param eterizableViewController] 2014-05-29 09:59:37.431 INFO 2756 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.springframework.web.servle t.resource.ResourceHttpRequestHandler] 2014-05-29 09:59:37.431 INFO 2756 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler] 2014-05-29 09:59:37.805 INFO 2756 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup 2014-05-29 09:59:37.868 INFO 2756 --- [ main] s.t.spring.security.config.Application : Started Application in 7.551 seconds (JVM running for 9.08)