Java Spring启动失败

Java Spring启动失败,java,spring,apache,spring-boot,tomcat,Java,Spring,Apache,Spring Boot,Tomcat,我有一个错误,我花了两个小时试图找出什么地方出了问题,但我无法修复它 我使用java-jar命令运行spring boot应用程序,它是一个包,无法启动 我将属性文件设置为将端口设置为80,并且禁用了我的firewalld,并且我在Centos7机器上运行。我尝试了netstat命令,但端口80没有服务,所以我认为这不是端口问题 这是错误日志: …日志说明了一切 配置为在端口80上侦听的Tomcat连接器无法启动。 端口可能已在使用中,或者连接器可能配置错误 当前正在使用该端口,此时可能有其他

我有一个错误,我花了两个小时试图找出什么地方出了问题,但我无法修复它

我使用
java-jar
命令运行spring boot应用程序,它是一个包,无法启动

我将属性文件设置为将端口设置为80,并且禁用了我的
firewalld
,并且我在Centos7机器上运行。我尝试了
netstat
命令,但端口80没有服务,所以我认为这不是端口问题

这是错误日志:


…日志说明了一切

配置为在端口80上侦听的Tomcat连接器无法启动。 端口可能已在使用中,或者连接器可能配置错误

当前正在使用该端口,此时可能有其他服务器正在使用该端口(可能需要另一次运行/调试?)。无论如何,出于发展的原因,我建议使用不同的端口


application.properties
put
server.port=8080
或类似的东西中,它被其他进程使用的可能性较小。

日志说明了一切

配置为在端口80上侦听的Tomcat连接器无法启动。 端口可能已在使用中,或者连接器可能配置错误

当前正在使用该端口,此时可能有其他服务器正在使用该端口(可能需要另一次运行/调试?)。无论如何,出于发展的原因,我建议使用不同的端口


application.properties
put
server.port=8080
或类似的东西中,它被其他进程使用的可能性更小。

java.net.SocketException:Permission denied
->(您的系统/环境是什么?)我相信在Linux上,您是一个使用端口80的“sudo”者。要么以超级用户身份运行,要么使用8080。@xerx593是的,所以在此之后我尝试了sudo,谢谢,但不幸的是,这不是一个问题。如果您尝试端口8080,它能工作吗?另外,检查netstat-a,看看是否有什么东西已经在使用端口80。
java.net.SocketException:Permission denied
->(您的系统/环境是什么?)我相信在Linux上,您是一个使用端口80的“sudo”者。要么以超级用户身份运行,要么使用8080。@xerx593是的,所以在此之后我尝试了sudo,谢谢,但不幸的是,这不是一个问题。如果您尝试端口8080,它能工作吗?另外,检查netstat-a以查看是否有东西已经在使用端口80。我假设spring boot将其服务器端口8080设置为默认端口。所以我用这个方法把它改成了80,它不起作用,但不知怎么解决了,因为我使用了嵌入式tomcat,它的设置使用servlet版本3.0而不是2.5,所以我在pom.xml中添加了依赖项,它得到了修复。谢谢你,tho!我认为spring boot将其服务器端口8080设置为默认端口。所以我用这个方法把它改成了80,它不起作用,但不知怎么解决了,因为我使用了嵌入式tomcat,它的设置使用servlet版本3.0而不是2.5,所以我在pom.xml中添加了依赖项,它得到了修复。谢谢你,tho!
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'