我试图在一个全新的Heroku应用程序上部署一个简单的Spring Boot应用程序。日志看起来很好,似乎它确实加载了我创建的所有bean和休息端点。
2017-08-08T01:13:06.328318+00:00 app[web.1]: Setting JAVA_TOOL_OPTIONS defaults based on dyno size. Custom settings will override them.
2017-08-08T01:13:06.331742+00:00 app[web.1]: Picked up JAVA_TOOL_OPTIONS: -Xmx350m -Xss512k -Dfile.encoding=UTF-8
2017-08-08T01:13:07.492271+00:00 app[web.1]:
2017-08-08T01:13:07.492313+00:00 app[web.1]: . ____ _ __ _ _
2017-08-08T01:13:07.492368+00:00 app[web.1]: /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
2017-08-08T01:13:07.492440+00:00 app[web.1]: ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
2017-08-08T01:13:07.492513+00:00 app[web.1]: \\/ ___)| |_)| | | | | || (_| | ) ) ) )
2017-08-08T01:13:07.492575+00:00 app[web.1]: ' |____| .__|_| |_|_| |_\__, | / / / /
2017-08-08T01:13:07.492635+00:00 app[web.1]: =========|_|==============|___/=/_/_/_/
2017-08-08T01:13:07.495462+00:00 app[web.1]: :: Spring Boot :: (v1.5.6.RELEASE)
2017-08-08T01:13:07.495498+00:00 app[web.1]:
2017-08-08T01:13:07.656174+00:00 app[web.1]: 2017-08-08 01:13:07.651 INFO 4 --- [ main] com.nem.swift.bc.main.Application : Starting Application v0.0.1-SNAPSHOT on fcd985c5-8723-4bd9-a4f5-14dcb623f5e0 with PID 4 (/app/target/nem-swift-blockchain-service-0.0.1-SNAPSHOT.jar started by u48179 in /app)
2017-08-08T01:13:07.656569+00:00 app[web.1]: 2017-08-08 01:13:07.656 INFO 4 --- [ main] com.nem.swift.bc.main.Application : No active profile set, falling back to default profiles: default
2017-08-08T01:13:07.821929+00:00 app[web.1]: 2017-08-08 01:13:07.821 INFO 4 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@32a1bec0: startup date [Tue Aug 08 01:13:07 UTC 2017]; root of context hierarchy
2017-08-08T01:13:10.509132+00:00 app[web.1]: 2017-08-08 01:13:10.508 INFO 4 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8013 (http)
2017-08-08T01:13:10.530905+00:00 app[web.1]: 2017-08-08 01:13:10.530 INFO 4 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2017-08-08T01:13:10.532394+00:00 app[web.1]: 2017-08-08 01:13:10.532 INFO 4 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.16
2017-08-08T01:13:10.701693+00:00 app[web.1]: 2017-08-08 01:13:10.701 INFO 4 --- [ost-startStop-1] o.a.c.c.C.[.[localhost].[/nemswiftsvc] : Initializing Spring embedded WebApplicationContext
2017-08-08T01:13:10.701872+00:00 app[web.1]: 2017-08-08 01:13:10.701 INFO 4 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 2884 ms
2017-08-08T01:13:11.059057+00:00 app[web.1]: 2017-08-08 01:13:11.058 INFO 4 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
2017-08-08T01:13:11.074497+00:00 app[web.1]: 2017-08-08 01:13:11.074 INFO 4 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2017-08-08T01:13:11.084607+00:00 app[web.1]: 2017-08-08 01:13:11.084 INFO 4 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2017-08-08T01:13:11.085008+00:00 app[web.1]: 2017-08-08 01:13:11.084 INFO 4 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2017-08-08T01:13:11.085246+00:00 app[web.1]: 2017-08-08 01:13:11.085 INFO 4 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2017-08-08T01:13:11.940954+00:00 app[web.1]: 2017-08-08 01:13:11.940 INFO 4 --- [ main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@32a1bec0: startup date [Tue Aug 08 01:13:07 UTC 2017]; root of context hierarchy
2017-08-08T01:13:12.127417+00:00 app[web.1]: 2017-08-08 01:13:12.127 INFO 4 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/],methods=[GET]}" onto public java.lang.String com.nem.swift.bc.service.HelloWorldService.ahoy()
2017-08-08T01:13:12.128759+00:00 app[web.1]: 2017-08-08 01:13:12.128 INFO 4 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/helloworld],methods=[GET]}" onto public java.lang.String com.nem.swift.bc.service.HelloWorldService.index()
2017-08-08T01:13:12.134591+00:00 app[web.1]: 2017-08-08 01:13:12.134 INFO 4 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/transaction/decode],methods=[POST],produces=[application/json]}" onto public com.nem.swift.bc.object.TransactionDecodeResponse com.nem.swift.bc.service.TransactionService.getDecodedMessage(com.nem.swift.bc.object.TransactionRequest)
2017-08-08T01:13:12.139337+00:00 app[web.1]: 2017-08-08 01:13:12.139 INFO 4 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/transaction/send],methods=[POST]}" onto public com.nem.swift.bc.object.TransactionResponse com.nem.swift.bc.service.TransactionService.sendTransaction(com.nem.swift.bc.object.TransactionRequest)
2017-08-08T01:13:12.146150+00:00 app[web.1]: 2017-08-08 01:13:12.144 INFO 4 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2017-08-08T01:13:12.146830+00:00 app[web.1]: 2017-08-08 01:13:12.146 INFO 4 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2017-08-08T01:13:12.253484+00:00 app[web.1]: 2017-08-08 01:13:12.253 INFO 4 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2017-08-08T01:13:12.254373+00:00 app[web.1]: 2017-08-08 01:13:12.253 INFO 4 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2017-08-08T01:13:12.326795+00:00 app[web.1]: 2017-08-08 01:13:12.326 INFO 4 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2017-08-08T01:13:12.667000+00:00 app[web.1]: 2017-08-08 01:13:12.666 INFO 4 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2017-08-08T01:13:12.790208+00:00 app[web.1]: 2017-08-08 01:13:12.789 INFO 4 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8013 (http)
2017-08-08T01:13:12.795047+00:00 app[web.1]: Let's inspect the beans provided by Spring Boot:
2017-08-08T01:13:12.795337+00:00 app[web.1]: application
2017-08-08T01:13:12.795396+00:00 app[web.1]: basicErrorController
2017-08-08T01:13:12.795637+00:00 app[web.1]: beanNameHandlerMapping
2017-08-08T01:13:12.795694+00:00 app[web.1]: beanNameViewResolver
2017-08-08T01:13:12.795742+00:00 app[web.1]: characterEncodingFilter
2017-08-08T01:13:12.795796+00:00 app[web.1]: commandLineRunner
2017-08-08T01:13:12.795851+00:00 app[web.1]: containerCustomizer
2017-08-08T01:13:12.795920+00:00 app[web.1]: conventionErrorViewResolver
2017-08-08T01:13:12.795971+00:00 app[web.1]: defaultServletHandlerMapping
2017-08-08T01:13:12.796021+00:00 app[web.1]: defaultValidator
2017-08-08T01:13:12.796094+00:00 app[web.1]: defaultViewResolver
2017-08-08T01:13:12.796130+00:00 app[web.1]: dispatcherServlet
2017-08-08T01:13:12.796185+00:00 app[web.1]: dispatcherServletRegistration
2017-08-08T01:13:12.796613+00:00 app[web.1]: duplicateServerPropertiesDetector
2017-08-08T01:13:12.796670+00:00 app[web.1]: embeddedServletContainerCustomizerBeanPostProcessor
2017-08-08T01:13:12.796721+00:00 app[web.1]: error
2017-08-08T01:13:12.796785+00:00 app[web.1]: errorAttributes
2017-08-08T01:13:12.796835+00:00 app[web.1]: errorPageCustomizer
2017-08-08T01:13:12.796888+00:00 app[web.1]: errorPageRegistrarBeanPostProcessor
2017-08-08T01:13:12.796956+00:00 app[web.1]: faviconHandlerMapping
2017-08-08T01:13:12.796987+00:00 app[web.1]: faviconRequestHandler
2017-08-08T01:13:12.797042+00:00 app[web.1]: handlerExceptionResolver
2017-08-08T01:13:12.797101+00:00 app[web.1]: helloWorldService
2017-08-08T01:13:12.797504+00:00 app[web.1]: hiddenHttpMethodFilter
2017-08-08T01:13:12.797663+00:00 app[web.1]: httpPutFormContentFilter
2017-08-08T01:13:12.797716+00:00 app[web.1]: httpRequestHandlerAdapter
2017-08-08T01:13:12.797769+00:00 app[web.1]: jacksonObjectMapper
2017-08-08T01:13:12.797835+00:00 app[web.1]: jacksonObjectMapperBuilder
2017-08-08T01:13:12.797867+00:00 app[web.1]: jsonComponentModule
2017-08-08T01:13:12.797935+00:00 app[web.1]: localeCharsetMappingsCustomizer
2017-08-08T01:13:12.797988+00:00 app[web.1]: mappingJackson2HttpMessageConverter
2017-08-08T01:13:12.798051+00:00 app[web.1]: mbeanExporter
2017-08-08T01:13:12.798094+00:00 app[web.1]: mbeanServer
2017-08-08T01:13:12.798145+00:00 app[web.1]: messageConverters
2017-08-08T01:13:12.798184+00:00 app[web.1]: methodValidationPostProcessor
2017-08-08T01:13:12.798236+00:00 app[web.1]: multipartConfigElement
2017-08-08T01:13:12.798290+00:00 app[web.1]: multipartResolver
2017-08-08T01:13:12.798359+00:00 app[web.1]: mvcContentNegotiationManager
2017-08-08T01:13:12.798389+00:00 app[web.1]: mvcConversionService
2017-08-08T01:13:12.798441+00:00 app[web.1]: mvcPathMatcher
2017-08-08T01:13:12.798499+00:00 app[web.1]: mvcResourceUrlProvider
2017-08-08T01:13:12.798537+00:00 app[web.1]: mvcUriComponentsContributor
2017-08-08T01:13:12.798956+00:00 app[web.1]: mvcUrlPathHelper
2017-08-08T01:13:12.798999+00:00 app[web.1]: mvcValidator
2017-08-08T01:13:12.799058+00:00 app[web.1]: mvcViewResolver
2017-08-08T01:13:12.799118+00:00 app[web.1]: objectNamingStrategy
2017-08-08T01:13:12.799547+00:00 app[web.1]: org.springframework.boot.autoconfigure.AutoConfigurationPackages
2017-08-08T01:13:12.808878+00:00 app[web.1]: org.springframework.boot.autoconfigure.condition.BeanTypeRegistry
2017-08-08T01:13:12.808950+00:00 app[web.1]: org.springframework.boot.autoconfigure.context.ConfigurationPropertiesAutoConfiguration
2017-08-08T01:13:12.809036+00:00 app[web.1]: org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration
2017-08-08T01:13:12.809096+00:00 app[web.1]: org.springframework.boot.autoconfigure.info.ProjectInfoAutoConfiguration
2017-08-08T01:13:12.809172+00:00 app[web.1]: org.springframework.boot.autoconfigure.internalCachingMetadataReaderFactory
2017-08-08T01:13:12.809227+00:00 app[web.1]: org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration
2017-08-08T01:13:12.809284+00:00 app[web.1]: org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration$Jackson2ObjectMapperBuilderCustomizerConfiguration
2017-08-08T01:13:12.809444+00:00 app[web.1]: org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration$JacksonObjectMapperBuilderConfiguration
2017-08-08T01:13:12.809496+00:00 app[web.1]: org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration$JacksonObjectMapperConfiguration
2017-08-08T01:13:12.809547+00:00 app[web.1]: org.springframework.boot.autoconfigure.jmx.JmxAutoConfiguration
2017-08-08T01:13:12.809600+00:00 app[web.1]: org.springframework.boot.autoconfigure.validation.ValidationAutoConfiguration
2017-08-08T01:13:12.809688+00:00 app[web.1]: org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration
2017-08-08T01:13:12.809763+00:00 app[web.1]: org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration$DispatcherServletConfiguration
2017-08-08T01:13:12.809822+00:00 app[web.1]: org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration$DispatcherServletRegistrationConfiguration
2017-08-08T01:13:12.809878+00:00 app[web.1]: org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration
2017-08-08T01:13:12.809936+00:00 app[web.1]: org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration$EmbeddedTomcat
2017-08-08T01:13:12.809990+00:00 app[web.1]: org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration
2017-08-08T01:13:12.810044+00:00 app[web.1]: org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration$DefaultErrorViewResolverConfiguration
2017-08-08T01:13:12.810116+00:00 app[web.1]: org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration$WhitelabelErrorViewConfiguration
2017-08-08T01:13:12.810166+00:00 app[web.1]: org.springframework.boot.autoconfigure.web.HttpEncodingAutoConfiguration
2017-08-08T01:13:12.810217+00:00 app[web.1]: org.springframework.boot.autoconfigure.web.HttpMessageConvertersAutoConfiguration
2017-08-08T01:13:12.810298+00:00 app[web.1]: org.springframework.boot.autoconfigure.web.HttpMessageConvertersAutoConfiguration$StringHttpMessageConverterConfiguration
2017-08-08T01:13:12.810371+00:00 app[web.1]: org.springframework.boot.autoconfigure.web.JacksonHttpMessageConvertersConfiguration
2017-08-08T01:13:12.810428+00:00 app[web.1]: org.springframework.boot.autoconfigure.web.JacksonHttpMessageConvertersConfiguration$MappingJackson2HttpMessageConverterConfiguration
2017-08-08T01:13:12.810484+00:00 app[web.1]: org.springframework.boot.autoconfigure.web.MultipartAutoConfiguration
2017-08-08T01:13:12.810541+00:00 app[web.1]: org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration
2017-08-08T01:13:12.810596+00:00 app[web.1]: org.springframework.boot.autoconfigure.web.WebClientAutoConfiguration
2017-08-08T01:13:12.810651+00:00 app[web.1]: org.springframework.boot.autoconfigure.web.WebClientAutoConfiguration$RestTemplateConfiguration
2017-08-08T01:13:12.810705+00:00 app[web.1]: org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration
2017-08-08T01:13:12.810761+00:00 app[web.1]: org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$EnableWebMvcConfiguration
2017-08-08T01:13:12.810817+00:00 app[web.1]: org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter
2017-08-08T01:13:12.810874+00:00 app[web.1]: org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter$FaviconConfiguration
2017-08-08T01:13:12.810926+00:00 app[web.1]: org.springframework.boot.autoconfigure.websocket.WebSocketAutoConfiguration
2017-08-08T01:13:12.810975+00:00 app[web.1]: org.springframework.boot.autoconfigure.websocket.WebSocketAutoConfiguration$TomcatWebSocketConfiguration
2017-08-08T01:13:12.811038+00:00 app[web.1]: org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor
2017-08-08T01:13:12.811092+00:00 app[web.1]: org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor.store
2017-08-08T01:13:12.811149+00:00 app[web.1]: org.springframework.context.annotation.internalAsyncAnnotationProcessor
2017-08-08T01:13:12.811208+00:00 app[web.1]: org.springframework.context.annotation.internalAutowiredAnnotationProcessor
2017-08-08T01:13:12.811262+00:00 app[web.1]: org.springframework.context.annotation.internalCommonAnnotationProcessor
2017-08-08T01:13:12.811316+00:00 app[web.1]: org.springframework.context.annotation.internalConfigurationAnnotationProcessor
2017-08-08T01:13:12.811373+00:00 app[web.1]: org.springframework.context.annotation.internalRequiredAnnotationProcessor
2017-08-08T01:13:12.811428+00:00 app[web.1]: org.springframework.context.event.internalEventListenerFactory
2017-08-08T01:13:12.811485+00:00 app[web.1]: org.springframework.context.event.internalEventListenerProcessor
2017-08-08T01:13:12.811539+00:00 app[web.1]: org.springframework.scheduling.annotation.ProxyAsyncConfiguration
2017-08-08T01:13:12.811595+00:00 app[web.1]: preserveErrorControllerTargetClassPostProcessor
2017-08-08T01:13:12.811649+00:00 app[web.1]: propertySourcesPlaceholderConfigurer
2017-08-08T01:13:12.811699+00:00 app[web.1]: requestContextFilter
2017-08-08T01:13:12.811745+00:00 app[web.1]: requestMappingHandlerAdapter
2017-08-08T01:13:12.811796+00:00 app[web.1]: requestMappingHandlerMapping
2017-08-08T01:13:12.811855+00:00 app[web.1]: resourceHandlerMapping
2017-08-08T01:13:12.811926+00:00 app[web.1]: restTemplateBuilder
2017-08-08T01:13:12.811975+00:00 app[web.1]: serverProperties
2017-08-08T01:13:12.812029+00:00 app[web.1]: simpleControllerHandlerAdapter
2017-08-08T01:13:12.812105+00:00 app[web.1]: spring.http.encoding-org.springframework.boot.autoconfigure.web.HttpEncodingProperties
2017-08-08T01:13:12.812167+00:00 app[web.1]: spring.http.multipart-org.springframework.boot.autoconfigure.web.MultipartProperties
2017-08-08T01:13:12.812232+00:00 app[web.1]: spring.info-org.springframework.boot.autoconfigure.info.ProjectInfoProperties
2017-08-08T01:13:12.812288+00:00 app[web.1]: spring.jackson-org.springframework.boot.autoconfigure.jackson.JacksonProperties
2017-08-08T01:13:12.812349+00:00 app[web.1]: spring.mvc-org.springframework.boot.autoconfigure.web.WebMvcProperties
2017-08-08T01:13:12.812403+00:00 app[web.1]: spring.resources-org.springframework.boot.autoconfigure.web.ResourceProperties
2017-08-08T01:13:12.812465+00:00 app[web.1]: standardJacksonObjectMapperBuilderCustomizer
2017-08-08T01:13:12.812512+00:00 app[web.1]: stringHttpMessageConverter
2017-08-08T01:13:12.812564+00:00 app[web.1]: tomcatEmbeddedServletContainerFactory
2017-08-08T01:13:12.812620+00:00 app[web.1]: transactionService
2017-08-08T01:13:12.812676+00:00 app[web.1]: viewControllerHandlerMapping
2017-08-08T01:13:12.812729+00:00 app[web.1]: viewResolver
2017-08-08T01:13:12.812778+00:00 app[web.1]: websocketContainerCustomizer
2017-08-08T01:13:12.812835+00:00 app[web.1]: welcomePageHandlerMapping
2017-08-08T01:13:12.815244+00:00 app[web.1]: 2017-08-08 01:13:12.815 INFO 4 --- [ main] com.nem.swift.bc.main.Application : Started Application in 5.799 seconds (JVM running for 6.483)
2017-08-08T01:14:34.970454+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 90 seconds of launch
2017-08-08T01:14:34.970566+00:00 heroku[web.1]: Stopping process with SIGKILL
2017-08-08T01:14:35.118469+00:00 heroku[web.1]: Process exited with status 137
2017-08-08T01:14:35.129172+00:00 heroku[web.1]: State changed from starting to crashed
2017-08-08T01:14:45.059295+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/nemswiftsvc/" host=swift-nem-bc.herokuapp.com request_id=af10beda-567b-429f-80a5-085c386a1f4c fwd="24.212.200.163" dyno= connect= service= status=503 bytes= protocol=https
2017-08-08T01:14:45.911470+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=swift-nem-bc.herokuapp.com request_id=7ca9c313-93ff-49fd-af77-4c629664ed98 fwd="24.212.200.163" dyno= connect= service= status=503 bytes= protocol=https
但是,每当我尝试访问测试端点时,它都会崩溃。每当我尝试访问基本的GET端点时,它似乎都会崩溃。
任何人都会遇到Heroku这个问题吗?
TIA
答案 0 :(得分:9)
我猜它是由端口引起的。我在我的proc文件中写这个并且工作
web: java -jar -Dserver.port=$PORT target/<application_deployed_name.jar>
我希望它有所帮助
修改强>
Spring文档支持这种简单的方法:
Spring Boot Reference Guide
答案 1 :(得分:5)
我设法通过将Heroku Assigned PORT设置为我的应用程序的默认端口来解决此问题。
我没有使用自己的PORT,而是使用System.getenv(“PORT”)强制我的应用程序使用Heroku分配的端口。
@Bean
public EmbeddedServletContainerCustomizer containerCustomizer() {
return (container -> {
container.setContextPath("/nemswiftsvc");
container.setPort(Integer.valueOf(System.getenv("PORT")));
});
}
答案 2 :(得分:1)
上面的答案有效!只需要一个小的补充(如果声明)让应用程序在本地运行,就像来自像eclipse这样的IDE
@Bean
public EmbeddedServletContainerCustomizer containerCustomizer() {
return (container -> {
container.setContextPath("");
if(System.getenv("PORT")!=null) {
container.setPort(Integer.valueOf(System.getenv("PORT")));
}
});
答案 3 :(得分:1)
晚了一点,但是您也可以简单地将server.port=${PORT:9000}
放在application.properties中。在这种情况下,如果找不到端口,则9000是应用程序将默认使用的端口。