質問: springbootを開始できませんでした エラーが発生し、2時間何が問題だったのかを突き止めようとしましたが、修正できません。java -jarコマンドを使用してspringbootアプリを実行しました。これはパッケージであり、起動できませんでした。プロパティファイルを設定してポートを80に設定し、firewalldを無効にして、centos7マシンで実行しました。 netstatコマンドを試しましたが、ポート80のサービスがなかったので、ポートの問題ではないと思います。これはエラーログです:2019-01-21 16:02:56.183 info 8158 --- [ main] com.springboot.pjsspringbootapplication : starting pjsspringbootapplication v1.0 on carpfishncptest1 with pid 8158 (/home/jh31/pjs-spring-boot/target/pjs-spring-boot-1.0.jar started by jh31 in /home/jh31/pjs-spring-boot/target) 2019-01-21 16:02:56.186 info 8158 --- [ main] com.springboot.pjsspringbootapplication : no active profile set, falling back to default profiles: default 2019-01-21 16:02:57.702 info 8158 --- [ main] o.s.b.w.embedded.tomcat.tomcatwebserver : tomcat initialized with port(s): 80 (http) 2019-01-21 16:02:57.729 info 8158 --- [ main] o.apache.catalina.core.standardservice : starting service [tomcat] 2019-01-21 16:02:57.730 info 8158 --- [ main] org.apache.catalina.core.standardengine : starting servlet engine: [apache tomcat/9.0.14] 2019-01-21 16:02:57.740 info 8158 --- [ main] o.a.catalina.core.aprlifecyclelistener : the apr based apache tomcat native library which allows optimal performance in production environments was not found on the java.library.path: [/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib] 2019-01-21 16:02:57.812 info 8158 --- [ main] o.a.c.c.c.[tomcat].[localhost].[/] : initializing spring embedded webapplicationcontext 2019-01-21 16:02:57.813 info 8158 --- [ main] o.s.web.context.contextloader : root webapplicationcontext: initialization completed in 1571 ms 2019-01-21 16:02:58.056 info 8158 --- [ main] o.s.s.concurrent.threadpooltaskexecutor : initializing executorservice 'applicationtaskexecutor' 2019-01-21 16:02:58.174 warn 8158 --- [ main] o.s.b.a.m.mustacheautoconfiguration : cannot find template location: classpath:/templates/ (please add some templates, check your mustache configuration, or set spring.mustache.check-template-location=false) 2019-01-21 16:02:58.192 info 8158 --- [ main] o.s.b.a.w.s.welcomepagehandlermapping : adding welcome page: class path resource [static/index.html] 2019-01-21 16:02:58.277 error 8158 --- [ main] org.apache.catalina.util.lifecyclebase : failed to start component [connector[http/1.1-80]] org.apache.catalina.lifecycleexception: protocol handler start failed at org.apache.catalina.connector.connector.startinternal(connector.java:1004) ~[tomcat-embed-core-9.0.14.jar!/:9.0.14] at org.apache.catalina.util.lifecyclebase.start(lifecyclebase.java:183) ~[tomcat-embed-core-9.0.14.jar!/:9.0.14] at org.apache.catalina.core.standardservice.addconnector(standardservice.java:226) [tomcat-embed-core-9.0.14.jar!/:9.0.14] at org.springframework.boot.web.embedded.tomcat.tomcatwebserver.addpreviouslyremovedconnectors(tomcatwebserver.java:259) [spring-boot-2.1.2.release.jar!/:2.1.2.release] at org.springframework.boot.web.embedded.tomcat.tomcatwebserver.start(tomcatwebserver.java:197) [spring-boot-2.1.2.release.jar!/:2.1.2.release] at org.springframework.boot.web.servlet.context.servletwebserverapplicationcontext.startwebserver(servletwebserverapplicationcontext.java:311) [spring-boot-2.1.2.release.jar!/:2.1.2.release] at org.springframework.boot.web.servlet.context.servletwebserverapplicationcontext.finishrefresh(servletwebserverapplicationcontext.java:164) [spring-boot-2.1.2.release.jar!/:2.1.2.release] at org.springframework.context.support.abstractapplicationcontext.refresh(abstractapplicationcontext.java:549) [spring-context-5.1.4.release.jar!/:5.1.4.release] at org.springframework.boot.web.servlet.context.servletwebserverapplicationcontext.refresh(servletwebserverapplicationcontext.java:142) [spring-boot-2.1.2.release.jar!/:2.1.2.release] at org.springframework.boot.springapplication.refresh(springapplication.java:775) [spring-boot-2.1.2.release.jar!/:2.1.2.release] at org.springframework.boot.springapplication.refreshcontext(springapplication.java:397) [spring-boot-2.1.2.release.jar!/:2.1.2.release] at org.springframework.boot.springapplication.run(springapplication.java:316) [spring-boot-2.1.2.release.jar!/:2.1.2.release] at org.springframework.boot.springapplication.run(springapplication.java:1260) [spring-boot-2.1.2.release.jar!/:2.1.2.release] at org.springframework.boot.springapplication.run(springapplication.java:1248) [spring-boot-2.1.2.release.jar!/:2.1.2.release] at com.springboot.pjsspringbootapplication.main(pjsspringbootapplication.java:10) [classes!/:1.0] at sun.reflect.nativemethodaccessorimpl.invoke0(native method) ~[na:1.8.0_201] at sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:62) ~[na:1.8.0_201] at sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) ~[na:1.8.0_201] at java.lang.reflect.method.invoke(method.java:498) ~[na:1.8.0_201] at org.springframework.boot.loader.mainmethodrunner.run(mainmethodrunner.java:48) [pjs-spring-boot-1.0.jar:1.0] at org.springframework.boot.loader.launcher.launch(launcher.java:87) [pjs-spring-boot-1.0.jar:1.0] at org.springframework.boot.loader.launcher.launch(launcher.java:50) [pjs-spring-boot-1.0.jar:1.0] at org.springframework.boot.loader.jarlauncher.main(jarlauncher.java:51) [pjs-spring-boot-1.0.jar:1.0] caused by: java.net.socketexception: permission denied at sun.nio.ch.net.bind0(native method) ~[na:1.8.0_201] at sun.nio.ch.net.bind(net.java:433) ~[na:1.8.0_201] at sun.nio.ch.net.bind(net.java:425) ~[na:1.8.0_201] at sun.nio.ch.serversocketchannelimpl.bind(serversocketchannelimpl.java:223) ~[na:1.8.0_201] at sun.nio.ch.serversocketadaptor.bind(serversocketadaptor.java:74) ~[na:1.8.0_201] at org.apache.tomcat.util.net.nioendpoint.initserversocket(nioendpoint.java:236) ~[tomcat-embed-core-9.0.14.jar!/:9.0.14] at org.apache.tomcat.util.net.nioendpoint.bind(nioendpoint.java:210) ~[tomcat-embed-core-9.0.14.jar!/:9.0.14] at org.apache.tomcat.util.net.abstractendpoint.bindwithcleanup(abstractendpoint.java:1085) ~[tomcat-embed-core-9.0.14.jar!/:9.0.14] at org.apache.tomcat.util.net.abstractendpoint.start(abstractendpoint.java:1171) ~[tomcat-embed-core-9.0.14.jar!/:9.0.14] at org.apache.coyote.abstractprotocol.start(abstractprotocol.java:568) ~[tomcat-embed-core-9.0.14.jar!/:9.0.14] at org.apache.catalina.connector.connector.startinternal(connector.java:1001) ~[tomcat-embed-core-9.0.14.jar!/:9.0.14] ... 22 common frames omitted 2019-01-21 16:02:58.282 info 8158 --- [ main] o.apache.catalina.core.standardservice : stopping service [tomcat] 2019-01-21 16:02:58.292 info 8158 --- [ main] conditionevaluationreportlogginglistener : error starting applicationcontext. to display the conditions report re-run your application with 'debug' enabled. 2019-01-21 16:02:58.293 error 8158 --- [ main] o.s.b.d.loggingfailureanalysisreporter : *************************** application failed to start *************************** description: the tomcat connector configured to listen on port 80 failed to start. the port may already be in use or the connector may be misconfigured. action: verify the connector's configuration, identify and stop any process that's listening on port 80, or configure this application to listen on another port. 2019-01-21 16:02:58.296 info 8158 --- [ main] o.s.s.concurrent.threadpooltaskexecutor : shutting down executorservice 'applicationtaskexecutor'
回答: 1024未満のポートは、rootユーザーのみに制限されています。 jarをrootとして実行してみてください。たとえばtomcatでアプリを実行する場合、tomcatはポート80を開くためにroot権限が必要です。