0
我使用MacOS的Sierra.And我用Springboot-CLI來產生一個空白的項目,並添加一個基本RESTController:SpringBoot不能聽端口
@GetMapping("/")
public Object index(){
return "hello world";
}
我運行project.Everything與似乎很大在控制檯輸出:
. ____ _ __ _ _
/\\/___'_ __ _ _(_)_ __ __ _ \ \ \ \
(()\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ))))
' |____| .__|_| |_|_| |_\__, |////
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.5.3.RELEASE)
2017-05-23 23:54:19.470 INFO 3776 --- [ main] com.bonc.smallETL.ETLApp : Starting ETLApp on SLs-Mac.local with PID 3776 (/Users/liuxiaoyang/Desktop/sourceCode/smallETL/smalletl-back/target/classes started by liuxiaoyang in /Users/liuxiaoyang/Desktop/sourceCode/smallETL/smalletl-back)
2017-05-23 23:54:19.473 INFO 3776 --- [ main] com.bonc.smallETL.ETLApp : No active profile set, falling back to default profiles: default
2017-05-23 23:54:19.571 INFO 3776 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot[email protected]2805c96b: startup date [Tue May 23 23:54:19 CST 2017]; root of context hierarchy
2017-05-23 23:54:21.126 INFO 3776 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 9999 (http)
2017-05-23 23:54:21.142 INFO 3776 --- [ main] o.apache.catalina.core.StandardService : Starting service Tomcat
2017-05-23 23:54:21.143 INFO 3776 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.14
2017-05-23 23:54:21.263 INFO 3776 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2017-05-23 23:54:21.264 INFO 3776 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1699 ms
2017-05-23 23:54:21.401 INFO 3776 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
2017-05-23 23:54:21.405 INFO 3776 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2017-05-23 23:54:21.405 INFO 3776 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2017-05-23 23:54:21.406 INFO 3776 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2017-05-23 23:54:21.407 INFO 3776 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
然而,當我打開瀏覽器並訪問http://localhost:9999(我用一套server.port在application.properties = 9999更改端口9999),事實證明,拒絕連接(也可通過捲曲)。因此,我用命令lsof -i:9999檢查端口也沒有任何問題。
# liuxiaoyang @ SLs-Mac in ~ [0:08:14]
$ lsof -i:9999
# liuxiaoyang @ SLs-Mac in ~ [0:14:59] C:1
$ sudo lsof -i:9999
Password:
# liuxiaoyang @ SLs-Mac in ~ [0:15:02] C:1
但是,一切看起來不錯,而jps命令顯示項目JVM已經啓動。 我想知道在一切看起來正確的時候,程序不能聽到配置的端口的原因。
當應用程序啓動時,它會列出它正在監聽的所有端口。該名單是9999?向我們展示啓動輸出。 – csmckelvey
嘗試推出'server.port = 8090' – Reborn
我試過了。我也以爲是端口問題。不過當我改了端口。沒有改變。@ Reborn – CALTyang