使用spring-boot运行java应用程序,并在digitalocean上运行 [英] Running a java application with spring-boot, and gradle on digitalocean

查看:258
本文介绍了使用spring-boot运行java应用程序,并在digitalocean上运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正试图用eclipse,java,gradle,spring-boot来构建一个安静的服务,并将其托管在数字海洋服务器上。当我访问特定端口或某些端口上的数字海洋URL时,我想得到一个JSON响应,所以我可以做123.456.78:90,并在浏览器中查看JSON。



当我在eclipse中运行并访问localhost时,这可以正常工作。访问本地主机:端口#提供所需的输出,但是我注意到eclipse的控制台日志和服务器上运行时的差异。



从eclipse: / p>

  2016-01-24 09:42:56.245 INFO 7372 --- [main] Keen.KeenAPICallTester:启动KeenAPICallTester on ** **  - 使用PID 7372(C:\Users\ **** \workspace\ ****  -  ML\bin由C:\Users\ ***中的****启动) * \workspace\ ****  -  ML)
2016-01-24 09:42:56.247 INFO 7372 --- [main] Keen.KeenAPICallTester:没有活动的配置文件设置,退回到默认配置文件:默认
2016-01-24 09:42:56.299 INFO 7372 --- [main] ationConfigEmbeddedWebApplicationContext:刷新org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@116af24:启动日期[Sun Jan 24 09:42: 56 EST 2016];根目录层次结构
2016-01-24 09:42:56.893 INFO 7372 --- [main] osbfsDefaultListableBeanFactory:用不同的定义覆盖bean'beanNameViewResolver'的bean定义:replace [Root bean:class [null ]。范围=;抽象= FALSE; lazyInit = FALSE; autowireMode = 3; dependencyCheck = 0; autowireCandidate = TRUE;初级= FALSE; factoryBeanName = org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration $ WhitelabelErrorViewConfiguration; factoryMethodName = beanNameViewResolver; initMethodName = NULL; destroyMethodName =(推断);在[root bean:class [null])中的类路径资源[org / springframework / boot / autoconfigure / web / ErrorMvcAutoConfiguration $ WhitelabelErrorViewConfiguration.class]]中定义。范围=;抽象= FALSE; lazyInit = FALSE; autowireMode = 3; dependencyCheck = 0; autowireCandidate = TRUE;初级= FALSE; factoryBeanName = org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration $ WebMvcAutoConfigurationAdapter; factoryMethodName = beanNameViewResolver; initMethodName = NULL; destroyMethodName =(推断);在类路径资源中定义[org / springframework / boot / autoconfigure / web / WebMvcAutoConfiguration $ WebMvcAutoConfigurationAdapter.class]]
2016-01-24 09:42:57.492 INFO 7372 --- [main] sbcetTomcatEmbeddedServletContainer:Tomcat已初始化与端口:9011(http)
2016-01-24 09:42:57.502 INFO 7372 --- [main] o.apache.catalina.core.StandardService:启动服务Tomcat
2016 -01-24 09:42:57.503 INFO 7372 --- [main] org.apache.catalina.core.StandardEngine:启动Servlet引擎:Apache Tomcat / 8.0.30
2016-01-24 09:42: 57.599 INFO 7372 --- [ost-startStop-1] oaccC [Tomcat]。[localhost]。[/]:初始化Spring嵌入式WebApplicationContext
2016-01-24 09:42:57.599 INFO 7372 --- [ ost-startStop-1] osweb.context.ContextLoader:Root WebApplicationContext:初始化在1301 ms完成
2016-01-24 09:42:57.880 INFO 7372 --- [ost-startStop-1] osbceServletRegistrationBean:嘛pping servlet:'dispatcherServlet'到[/]
2016-01-24 09:42:57.883 INFO 7372 --- [ost-startStop-1] osbcembedded.FilterRegistrationBean:映射过滤器:'characterEncodingFilter' / *]
2016-01-24 09:42:57.884 INFO 7372 --- [ost-startStop-1] osbcembedded.FilterRegistrationBean:映射过滤器:'hiddenHttpMethodFilter'到:[/ *]
2016-01-24 09:42:57.884 INFO 7372 --- [ost-startStop-1] osbcembedded.FilterRegistrationBean:映射过滤器:'httpPutFormContentFilter'到:[/ *]
2016-01-24 09: 42:57.885 INFO 7372 --- [ost-startStop-1] osbcembedded.FilterRegistrationBean:映射过滤器:'requestContextFilter'到:[/ *]
2016-01-24 09:42:58.120 INFO 7372 - - [main] swsmmaRequestMappingHandlerAdapter:寻找@ControllerAdvice:org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@116af24:启动日期[Sun Jan 24 09:42:56 EST 2016];根据上下文层次结构
2016-01-24 09:42:58.183 INFO 7372 --- [main] swsmmaRequestMappingHandlerMapping:映射{[/ extractTest],methods = [GET],produce = [application / json] }到public java.lang.Object Keen.MLJSONResponseController.testExtractionRequest()
2016-01-24 09:42:58.184 INFO 7372 --- [main] swsmmaRequestMappingHandlerMapping:映射{[/ inspectAllProjectsTest],方法= [GET],generate = [application / json]}到public java.lang.Object Keen.MLJSONResponseController.testInspectionRequest()
2016-01-24 09:42:58.186 INFO 7372 --- [main] swsmmaRequestMappingHandlerMapping:将{[/ error]}映射到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)
2016-01-24 09:42:58.186 INFO 7372 --- [main] swsmmaRequestMappingHandlerMapping:映射{ [/ error],produce = [text / html]}到public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet .http.HttpServletResponse)
2016-01-24 09:42:58.208 INFO 7372 --- [main] oswshandler.SimpleUrlHandlerMapping:映射URL路径[/ webjars / **]到类型为[class org。 springframework.web.servlet.resource.ResourceHttpRequestHandler]
2016-01-24 09:42:58.208 INFO 7372 --- [main] oswshandler.SimpleUrlHandlerMapping:映射URL路径[/ **]到类型为[ class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2016-01-24 09:42:58.246 INFO 7372 --- [main] oswshandler.Si mpleUrlHandlerMapping:映射的URL路径[/n/favicon.ico]到类型为[class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]的处理程序
2016-01-24 09:42:58.349 INFO 7372 - - [main] osjeaAnnotationMBeanExporter:在启​​动时注册JMX暴露的bean
2016-01-24 09:42:58.402 INFO 7372 --- [main] sbcetTomcatEmbeddedServletContainer:Tomcat在端口上启动:9011(http )
2016-01-24 09:42:58.406 INFO 7372 --- [main] Keen.KeenAPICallTester:在2.445秒内启动KeenAPICallTester(JVM运行2.739)
/ pre>

从数字海洋:

  09:22:11.190 INFO 29453 --- [main] Keen.KeenAPICallTester:使用PID 29453启动KeenAPICallTester on ****(/ root / java-ml / learn / build / classes / main由root / root / java启动-ml / learning)
2016-01-24 09:22:11.224 INFO 29453 --- [m ain] Keen.KeenAPICallTester:没有活动的配置文件设置,退回到默认配置文件:默认
2016-01-24 09:22:11.949 INFO 29453 --- [main] ationConfigEmbeddedWebApplicationContext:刷新org.springframework.boot.context .embedded.AnnotationConfigEmbeddedWebApplicationContext @ 8b87145:启动日期[Sun Jan 24 09:22:11 EST 2016];根目录层次结构
2016-01-24 09:22:16.874 INFO 29453 --- [main] osbfsDefaultListableBeanFactory:使用不同的定义覆盖bean'beanNameViewResolver'的bean定义:replace [Root bean:class [null ]。范围=;抽象= FALSE; lazyInit = FALSE; autowireMode = 3; dependencyCheck = 0; autowireCandidate = TRUE;初级= FALSE; factoryBeanName = org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration $ WhitelabelErrorViewConfiguration; factoryMethodName = beanNameViewResolver; initMethodName = NULL; destroyMethodName =(推断);在[root bean:class [null])中的类路径资源[org / springframework / boot / autoconfigure / web / ErrorMvcAutoConfiguration $ WhitelabelErrorViewConfiguration.class]]中定义。范围=;抽象= FALSE; lazyInit = FALSE; autowireMode = 3; dependencyCheck = 0; autowireCandidate = TRUE;初级= FALSE; factoryBeanName = org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration $ WebMvcAutoConfigurationAdapter; factoryMethodName = beanNameViewResolver; initMethodName = NULL; destroyMethodName =(推断);在类路径资源中定义[org / springframework / boot / autoconfigure / web / WebMvcAutoConfiguration $ WebMvcAutoConfigurationAdapter.class]]
2016-01-24 09:22:20.350 INFO 29453 --- [main] sbcetTomcatEmbeddedServletContainer:与港口:80(http)
2016-01-24 09:22:20.448 INFO 29453 --- [main] o.apache.catalina.core.StandardService:启动服务Tomcat
2016 -01-24 09:22:20.457 INFO 29453 --- [main] org.apache.catalina.core.StandardEngine:启动Servlet引擎:Apache Tomcat / 8.0.30
2016-01-24 09:22: 21.015 INFO 29453 --- [ost-startStop-1] oaccC [Tomcat]。[localhost]。[/]:初始化Spring嵌入式WebApplicationContext
2016-01-24 09:22:21.016 INFO 29453 --- [ ost-startStop-1] osweb.context.ContextLoader:Root WebApplicationContext:初始化在9086 ms中完成
2016-01-24 09:22:22.582 INFO 29453 --- [ost-startStop-1] osbceServletRegistrationBean :映射servlet:'dispatcherServlet'到[/]
2016-01-24 09:22:22.613 INFO 29453 --- [ost-startStop-1] osbcembedded.FilterRegistrationBean:映射过滤器:'characterEncodingFilter' [/ *]
2016-01-24 09:22:22.636 INFO 29453 --- [ost-startStop-1] osbcembedded.FilterRegistrationBean:映射过滤器:'hiddenHttpMethodFilter'到:[/ *]
2016-01-24 09:22:22.637 INFO 29453 --- [ost-startStop-1] osbcembedded.FilterRegistrationBean:映射过滤器:'httpPutFormContentFilter'到:[/ *]
2016-01-24 09 :22:22.637 INFO 29453 --- [ost-startStop-1] osbcembedded.FilterRegistrationBean:映射过滤器:'requestContextFilter'到:[/ *]

我的猜测是,由于某种原因,我的数字海洋服务器不是很好玩与Tomcat或某事。我通过 ufw 命令打开端口,检查iptables,安装的apache2(我甚至不知道我是否必须诚实),并确保有配置设置为接受8080和8000端口的出站和入站请求。



我注意到我的请求方法没有被映射,这让我觉得有一些依赖问题。这是我的 build.gradle 作为参考。

  buildscript {
存储库{
mavenCentral()
}
依赖关系{
classpath(org.springframework.boot:spring-boot-gradle-plugin:1.3.1.RELEASE)

}
}

应用插件:'java'
应用插件:'应用'
应用插件:'eclipse'
应用插件:'idea'
应用插件:'spring-boot'

mainClassName =Keen.KeenAPICallTester
applicationDefaultJvmArgs = [--server.port = 8000 ]

jar {
baseName ='**** - ML'
version ='0.1.0'
}

存储库{
mavenCentral()
}

sourceCompatibility = 1.8
targetCompatibility = 1.8



依赖项{
compile(org.springframework.boot:spring-boot-starter-web)
testCompile(junit:junit)
编译fileTree(dir:'libs',include:' * .jar')
}

任务包装(类型:Wrapper){
gradleVersion ='2.3'
}

任务(runSimple,dependsOn:'classes ',键入:JavaExec){
main ='Keen.KeenAPICallTester'
classpath = sourceSets.main.runtimeClasspath
args'--server.port = 8000'
}

我正在处理这个问题有什么问题吗?我还有一个 runSimple 命令,以便我可以玩JVM端口运行,但它没有什么区别,即使我把它设置为80,直接到默认的数字海洋IP地址。



我以前在数字海洋上运行过应用程序,通常是通过 ufw 并在端口上运行应用程序,然后通过互联网访问它。但是有一些事情正在发生,我想了解。

解决方案

似乎应用程序被卡住,因为它可能等待 / dev / random (阻止设备,可能会干涸)。



您可以使用 / dev / urandom 而不是启动你的应用程序传递JVM-param -Djava.security.egd = file:/ dev /./ urandom



请参阅避免随机数生成导致的JVM延迟



此外,为了深入研究这样奇怪的问题,诸如 jstack strace 可能有帮助。


I am trying to build a restful service with eclipse, java, gradle, spring-boot and host it on a digital ocean server. I want to get a JSON response when I access the digital ocean url on a specific port or something, so I can do 123.456.78:90 and see JSON in the browser.

When I run this in eclipse and access localhost, this works fine. Accessing localhost:port# gives the desired output, but I'm noticing differences in the console log from eclipse and when I run it on the server.

From eclipse:

2016-01-24 09:42:56.245  INFO 7372 --- [           main] Keen.KeenAPICallTester                   : Starting KeenAPICallTester on ****-THINK with PID 7372 (C:\Users\****\workspace\****-ML\bin started by **** in C:\Users\****\workspace\****-ML)
2016-01-24 09:42:56.247  INFO 7372 --- [           main] Keen.KeenAPICallTester                   : No active profile set, falling back to default profiles: default
2016-01-24 09:42:56.299  INFO 7372 --- [           main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@116af24: startup date [Sun Jan 24 09:42:56 EST 2016]; root of context hierarchy
2016-01-24 09:42:56.893  INFO 7372 --- [           main] o.s.b.f.s.DefaultListableBeanFactory     : Overriding bean definition for bean 'beanNameViewResolver' with a different definition: replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration$WhitelabelErrorViewConfiguration; factoryMethodName=beanNameViewResolver; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/web/ErrorMvcAutoConfiguration$WhitelabelErrorViewConfiguration.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter; factoryMethodName=beanNameViewResolver; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter.class]]
2016-01-24 09:42:57.492  INFO 7372 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 9011 (http)
2016-01-24 09:42:57.502  INFO 7372 --- [           main] o.apache.catalina.core.StandardService   : Starting service Tomcat
2016-01-24 09:42:57.503  INFO 7372 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.0.30
2016-01-24 09:42:57.599  INFO 7372 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2016-01-24 09:42:57.599  INFO 7372 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 1301 ms
2016-01-24 09:42:57.880  INFO 7372 --- [ost-startStop-1] o.s.b.c.e.ServletRegistrationBean        : Mapping servlet: 'dispatcherServlet' to [/]
2016-01-24 09:42:57.883  INFO 7372 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean  : Mapping filter: 'characterEncodingFilter' to: [/*]
2016-01-24 09:42:57.884  INFO 7372 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean  : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2016-01-24 09:42:57.884  INFO 7372 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean  : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2016-01-24 09:42:57.885  INFO 7372 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean  : Mapping filter: 'requestContextFilter' to: [/*]
2016-01-24 09:42:58.120  INFO 7372 --- [           main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@116af24: startup date [Sun Jan 24 09:42:56 EST 2016]; root of context hierarchy
2016-01-24 09:42:58.183  INFO 7372 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/extractionTest],methods=[GET],produces=[application/json]}" onto public java.lang.Object Keen.MLJSONResponseController.testExtractionRequest()
2016-01-24 09:42:58.184  INFO 7372 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/inspectAllProjectsTest],methods=[GET],produces=[application/json]}" onto public java.lang.Object Keen.MLJSONResponseController.testInspectionRequest()
2016-01-24 09:42:58.186  INFO 7372 --- [           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)
2016-01-24 09:42:58.186  INFO 7372 --- [           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)
2016-01-24 09:42:58.208  INFO 7372 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2016-01-24 09:42:58.208  INFO 7372 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2016-01-24 09:42:58.246  INFO 7372 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2016-01-24 09:42:58.349  INFO 7372 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
2016-01-24 09:42:58.402  INFO 7372 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 9011 (http)
2016-01-24 09:42:58.406  INFO 7372 --- [           main] Keen.KeenAPICallTester                   : Started KeenAPICallTester in 2.445 seconds (JVM running for 2.739)

From Digital Ocean:

2016-01-24 09:22:11.190  INFO 29453 --- [           main] Keen.KeenAPICallTester                   : Starting KeenAPICallTester on **** with PID 29453 (/root/java-ml/learning/build/classes/main started by root in /root/java-ml/learning)
2016-01-24 09:22:11.224  INFO 29453 --- [           main] Keen.KeenAPICallTester                   : No active profile set, falling back to default profiles: default
2016-01-24 09:22:11.949  INFO 29453 --- [           main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@8b87145: startup date [Sun Jan 24 09:22:11 EST 2016]; root of context hierarchy
2016-01-24 09:22:16.874  INFO 29453 --- [           main] o.s.b.f.s.DefaultListableBeanFactory     : Overriding bean definition for bean 'beanNameViewResolver' with a different definition: replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration$WhitelabelErrorViewConfiguration; factoryMethodName=beanNameViewResolver; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/web/ErrorMvcAutoConfiguration$WhitelabelErrorViewConfiguration.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter; factoryMethodName=beanNameViewResolver; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter.class]]
2016-01-24 09:22:20.350  INFO 29453 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 80 (http)
2016-01-24 09:22:20.448  INFO 29453 --- [           main] o.apache.catalina.core.StandardService   : Starting service Tomcat
2016-01-24 09:22:20.457  INFO 29453 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.0.30
2016-01-24 09:22:21.015  INFO 29453 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2016-01-24 09:22:21.016  INFO 29453 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 9086 ms
2016-01-24 09:22:22.582  INFO 29453 --- [ost-startStop-1] o.s.b.c.e.ServletRegistrationBean        : Mapping servlet: 'dispatcherServlet' to [/]
2016-01-24 09:22:22.613  INFO 29453 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean  : Mapping filter: 'characterEncodingFilter' to: [/*]
2016-01-24 09:22:22.636  INFO 29453 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean  : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2016-01-24 09:22:22.637  INFO 29453 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean  : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2016-01-24 09:22:22.637  INFO 29453 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean  : Mapping filter: 'requestContextFilter' to: [/*]

My guess is that for some reason my digital ocean server isn't playing nice with Tomcat or something. I opened ports via the ufw command, checked iptables, installed apache2 (I don't even know if I had to to be honest) and made sure that there were configurations set to accept outbound and inbound requests in port 8080 and 8000.

I noticed that my request methods are not getting mapped, which makes me think that there is some dependency problem. Here is my build.gradle for reference.

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:1.3.1.RELEASE")

    }
}

apply plugin: 'java'
apply plugin: 'application'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'spring-boot'

mainClassName = "Keen.KeenAPICallTester"
applicationDefaultJvmArgs = ["--server.port=8000"]

jar {
    baseName = '****-ML'
    version =  '0.1.0'
}

repositories {
    mavenCentral()
}

sourceCompatibility = 1.8
targetCompatibility = 1.8



dependencies {
    compile("org.springframework.boot:spring-boot-starter-web")
    testCompile("junit:junit")
    compile fileTree(dir: 'libs', include: '*.jar')
}

task wrapper(type: Wrapper) {
    gradleVersion = '2.3'
}

task(runSimple, dependsOn: 'classes', type: JavaExec) {
    main = 'Keen.KeenAPICallTester'
    classpath = sourceSets.main.runtimeClasspath
    args '--server.port=8000'
}

Is there something wrong with the way I'm handling this? I also have a runSimple command so that I could play with the JVM port run, but it makes no difference, even if I set it to 80 and go straight to the default digital ocean IP address.

I've run applications on digital ocean before and usually it was as simple as opening a specific port via ufw and running the application on the port, then accessing it via the internet. But there's something under the hood that's going on that I would like to understand.

解决方案

Seems like the application is stuck because it might be waiting for /dev/random (blocking device, might have run dry).

You could use /dev/urandom instead by starting your application passing the JVM-param -Djava.security.egd=file:/dev/./urandom.

See Avoiding JVM Delays Caused by Random Number Generation

Furthermore, to drill down such weird issues, tools such as jstack or strace might be of help.

这篇关于使用spring-boot运行java应用程序,并在digitalocean上运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆