启动Spring应用程序地址已经在使用中

我有这个错误启动我的spring的应用程序:

java -jar target/gs-serving-web-content-0.1.0.jar . ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v0.5.0.M6) 2013-12-23 00:23:09.466 INFO 19252 --- [ main] hello.Application : Starting Application on mbp-de-antoine.home with PID 19252 (/Users/antoine/Documents/workspace-sts-3.4.0.RELEASE/springapp/target/gs-serving-web-content-0.1.0.jar started by antoine) 2013-12-23 00:23:09.511 INFO 19252 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@24024c39: startup date [Mon Dec 23 00:23:09 CET 2013]; root of context hierarchy 2013-12-23 00:23:10.910 INFO 19252 --- [ main] o.apache.catalina.core.StandardService : Starting service Tomcat 2013-12-23 00:23:10.910 INFO 19252 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/7.0.42 2013-12-23 00:23:11.045 INFO 19252 --- [ost-startStop-1] oaccC[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext 2013-12-23 00:23:11.046 INFO 19252 --- [ost-startStop-1] osweb.context.ContextLoader : Root WebApplicationContext: initialization completed in 1537 ms 2013-12-23 00:23:11.274 INFO 19252 --- [ost-startStop-1] oaccC[Tomcat].[localhost].[/] : Initializing Spring FrameworkServlet 'dispatcherServlet' 2013-12-23 00:23:11.274 INFO 19252 --- [ost-startStop-1] osweb.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet': initialization started 2013-12-23 00:23:11.409 INFO 19252 --- [ost-startStop-1] oswshandler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler] 2013-12-23 00:23:11.634 INFO 19252 --- [ost-startStop-1] swsmmaRequestMappingHandlerMapping : Mapped "{[/greeting],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String hello.GreetingController.greeting(java.lang.String,org.springframework.ui.Model) 2013-12-23 00:23:11.717 INFO 19252 --- [ost-startStop-1] oswshandler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler] 2013-12-23 00:23:11.717 INFO 19252 --- [ost-startStop-1] oswshandler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler] 2013-12-23 00:23:12.406 INFO 19252 --- [ost-startStop-1] osweb.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet': initialization completed in 1132 ms 2013-12-23 00:23:12.417 ERROR 19252 --- [ main] oacoyote.http11.Http11NioProtocol : Failed to start end point associated with ProtocolHandler ["http-nio-8080"] java.net.BindException: Address already in use at sun.nio.ch.Net.bind0(Native Method) at sun.nio.ch.Net.bind(Net.java:444) at sun.nio.ch.Net.bind(Net.java:436) at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:214) at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74) at org.apache.tomcat.util.net.NioEndpoint.bind(NioEndpoint.java:473) at org.apache.tomcat.util.net.AbstractEndpoint.start(AbstractEndpoint.java:617) at org.apache.coyote.AbstractProtocol.start(AbstractProtocol.java:444) at org.apache.catalina.connector.Connector.startInternal(Connector.java:1010) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.StandardService.startInternal(StandardService.java:459) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:732) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.startup.Tomcat.start(Tomcat.java:335) at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.initialize(TomcatEmbeddedServletContainer.java:58) at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.<init>(TomcatEmbeddedServletContainer.java:53) at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getTomcatEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:259) at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:140) at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:158) at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:135) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:476) at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:552) at org.springframework.boot.SpringApplication.run(SpringApplication.java:293) at org.springframework.boot.SpringApplication.run(SpringApplication.java:749) at org.springframework.boot.SpringApplication.run(SpringApplication.java:738) at hello.Application.main(Application.java:12) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:53) at java.lang.Thread.run(Thread.java:744) 2013-12-23 00:23:12.419 ERROR 19252 --- [ main] o.apache.catalina.core.StandardService : Failed to start connector [Connector[org.apache.coyote.http11.Http11NioProtocol-8080]] org.apache.catalina.LifecycleException: Failed to start component [Connector[org.apache.coyote.http11.Http11NioProtocol-8080]] at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154) at org.apache.catalina.core.StandardService.startInternal(StandardService.java:459) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:732) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.startup.Tomcat.start(Tomcat.java:335) at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.initialize(TomcatEmbeddedServletContainer.java:58) at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.<init>(TomcatEmbeddedServletContainer.java:53) at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getTomcatEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:259) at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:140) at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:158) at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:135) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:476) at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:552) at org.springframework.boot.SpringApplication.run(SpringApplication.java:293) at org.springframework.boot.SpringApplication.run(SpringApplication.java:749) at org.springframework.boot.SpringApplication.run(SpringApplication.java:738) at hello.Application.main(Application.java:12) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:53) at java.lang.Thread.run(Thread.java:744) Caused by: org.apache.catalina.LifecycleException: service.getName(): "Tomcat"; Protocol handler start failed at org.apache.catalina.connector.Connector.startInternal(Connector.java:1017) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) ... 24 common frames omitted Caused by: java.net.BindException: Address already in use at sun.nio.ch.Net.bind0(Native Method) at sun.nio.ch.Net.bind(Net.java:444) at sun.nio.ch.Net.bind(Net.java:436) at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:214) at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74) at org.apache.tomcat.util.net.NioEndpoint.bind(NioEndpoint.java:473) at org.apache.tomcat.util.net.AbstractEndpoint.start(AbstractEndpoint.java:617) at org.apache.coyote.AbstractProtocol.start(AbstractProtocol.java:444) at org.apache.catalina.connector.Connector.startInternal(Connector.java:1010) ... 25 common frames omitted 2013-12-23 00:23:12.420 INFO 19252 --- [ main] o.apache.catalina.core.StandardService : Stopping service Tomcat 2013-12-23 00:23:12.430 INFO 19252 --- [ main] nitializer$AutoConfigurationReportLogger : ========================= AUTO-CONFIGURATION REPORT ========================= Positive matches: ----------------- MessageSourceAutoConfiguration - @ConditionalOnMissingBean (types: org.springframework.context.MessageSource; SearchStrategy: all) found no beans (OnBeanCondition) PropertyPlaceholderAutoConfiguration#propertySourcesPlaceholderConfigurer - @ConditionalOnMissingBean (types: org.springframework.context.support.PropertySourcesPlaceholderConfigurer; SearchStrategy: current) found no beans (OnBeanCondition) ThymeleafAutoConfiguration - @ConditionalOnClass classes found: org.thymeleaf.spring3.SpringTemplateEngine (OnClassCondition) - @ConditionalOnClass classes found: org.thymeleaf.spring3.SpringTemplateEngine (OnClassCondition) ThymeleafAutoConfiguration.DefaultTemplateResolverConfiguration - @ConditionalOnMissingBean (names: defaultTemplateResolver; SearchStrategy: all) found no beans (OnBeanCondition) ThymeleafAutoConfiguration.ThymeleafDefaultConfiguration - @ConditionalOnMissingBean (types: org.thymeleaf.spring3.SpringTemplateEngine; SearchStrategy: all) found no beans (OnBeanCondition) ThymeleafAutoConfiguration.ThymeleafViewResolverConfiguration - @ConditionalOnClass classes found: javax.servlet.Servlet (OnClassCondition) - @ConditionalOnClass classes found: javax.servlet.Servlet (OnClassCondition) ThymeleafAutoConfiguration.ThymeleafViewResolverConfiguration#thymeleafViewResolver - @ConditionalOnMissingBean (names: thymeleafViewResolver; SearchStrategy: all) found no beans (OnBeanCondition) DispatcherServletAutoConfiguration - found web application StandardServletEnvironment (OnWebApplicationCondition) - @ConditionalOnClass classes found: org.springframework.web.servlet.DispatcherServlet (OnClassCondition) - found web application StandardServletEnvironment (OnWebApplicationCondition) - @ConditionalOnClass classes found: org.springframework.web.servlet.DispatcherServlet (OnClassCondition) - @ConditionalOnBean (types: org.springframework.boot.context.embedded.EmbeddedServletContainerFactory; SearchStrategy: all) found the following [tomcatEmbeddedServletContainerFactory] (OnBeanCondition) DispatcherServletAutoConfiguration#dispatcherServlet - no DispatcherServlet found (DispatcherServletAutoConfiguration.DefaultDispatcherServletCondition) EmbeddedServletContainerAutoConfiguration - found web application StandardServletEnvironment (OnWebApplicationCondition) - found web application StandardServletEnvironment (OnWebApplicationCondition) EmbeddedServletContainerAutoConfiguration.EmbeddedTomcat - @ConditionalOnClass classes found: javax.servlet.Servlet,org.apache.catalina.startup.Tomcat (OnClassCondition) - @ConditionalOnClass classes found: javax.servlet.Servlet,org.apache.catalina.startup.Tomcat (OnClassCondition) - @ConditionalOnMissingBean (types: org.springframework.boot.context.embedded.EmbeddedServletContainerFactory; SearchStrategy: current) found no beans (OnBeanCondition) ServerPropertiesAutoConfiguration#serverProperties - @ConditionalOnMissingBean (types: org.springframework.boot.context.embedded.properties.ServerProperties; SearchStrategy: all) found no beans (OnBeanCondition) WebMvcAutoConfiguration - found web application StandardServletEnvironment (OnWebApplicationCondition) - @ConditionalOnClass classes found: javax.servlet.Servlet,org.springframework.web.servlet.DispatcherServlet,org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter (OnClassCondition) - found web application StandardServletEnvironment (OnWebApplicationCondition) - @ConditionalOnClass classes found: javax.servlet.Servlet,org.springframework.web.servlet.DispatcherServlet,org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter (OnClassCondition) - @ConditionalOnMissingBean (types: org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport; SearchStrategy: all) found no beans (OnBeanCondition) WebMvcAutoConfiguration#hiddenHttpMethodFilter - @ConditionalOnMissingBean (types: org.springframework.web.filter.HiddenHttpMethodFilter; SearchStrategy: all) found no beans (OnBeanCondition) WebMvcAutoConfiguration.WebMvcAutoConfigurationAdapter#defaultViewResolver - @ConditionalOnMissingBean (types: org.springframework.web.servlet.view.InternalResourceViewResolver; SearchStrategy: all) found no beans (OnBeanCondition) Negative matches: ----------------- RabbitAutoConfiguration - required @ConditionalOnClass classes not found: org.springframework.amqp.rabbit.core.RabbitTemplate,com.rabbitmq.client.Channel (OnClassCondition) AopAutoConfiguration - required @ConditionalOnClass classes not found: org.aspectj.lang.annotation.Aspect,org.aspectj.lang.reflect.Advice (OnClassCondition) BatchAutoConfiguration - required @ConditionalOnClass classes not found: org.springframework.batch.core.launch.JobLauncher (OnClassCondition) JpaRepositoriesAutoConfiguration - required @ConditionalOnClass classes not found: org.springframework.data.jpa.repository.JpaRepository (OnClassCondition) MongoRepositoriesAutoConfiguration - required @ConditionalOnClass classes not found: com.mongodb.Mongo,org.springframework.data.mongodb.repository.MongoRepository (OnClassCondition) DataSourceAutoConfiguration - required @ConditionalOnClass classes not found: org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType (OnClassCondition) DataSourceTransactionManagerAutoConfiguration - required @ConditionalOnClass classes not found: org.springframework.jdbc.core.JdbcTemplate,org.springframework.transaction.PlatformTransactionManager (OnClassCondition) JmsTemplateAutoConfiguration - required @ConditionalOnClass classes not found: org.springframework.jms.core.JmsTemplate,javax.jms.ConnectionFactory (OnClassCondition) DeviceResolverAutoConfiguration - required @ConditionalOnClass classes not found: org.springframework.mobile.device.DeviceResolverHandlerInterceptor,org.springframework.mobile.device.DeviceHandlerMethodArgumentResolver (OnClassCondition) HibernateJpaAutoConfiguration - required @ConditionalOnClass classes not found: org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean,org.springframework.transaction.annotation.EnableTransactionManagement,javax.persistence.EntityManager,org.hibernate.ejb.HibernateEntityManager (OnClassCondition) ReactorAutoConfiguration - required @ConditionalOnClass classes not found: reactor.spring.context.config.EnableReactor (OnClassCondition) ThymeleafAutoConfiguration.ThymeleafSecurityDialectConfiguration - required @ConditionalOnClass classes not found: org.thymeleaf.extras.springsecurity3.dialect.SpringSecurityDialect (OnClassCondition) ThymeleafAutoConfiguration.ThymeleafWebLayoutConfiguration - required @ConditionalOnClass classes not found: nz.net.ultraq.thymeleaf.LayoutDialect (OnClassCondition) EmbeddedServletContainerAutoConfiguration.EmbeddedJetty - required @ConditionalOnClass classes not found: org.eclipse.jetty.server.Server,org.eclipse.jetty.util.Loader (OnClassCondition) MultipartAutoConfiguration - @ConditionalOnClass classes found: javax.servlet.Servlet,org.springframework.web.multipart.support.StandardServletMultipartResolver (OnClassCondition) - @ConditionalOnClass classes found: javax.servlet.Servlet,org.springframework.web.multipart.support.StandardServletMultipartResolver (OnClassCondition) - @ConditionalOnBean (types: javax.servlet.MultipartConfigElement; SearchStrategy: all) found no beans (OnBeanCondition) WebMvcAutoConfiguration.WebMvcAutoConfigurationAdapter#beanNameViewResolver - @ConditionalOnBean (types: org.springframework.web.servlet.View; SearchStrategy: all) found no beans (OnBeanCondition) WebMvcAutoConfiguration.WebMvcAutoConfigurationAdapter#viewResolver - @ConditionalOnBean (types: org.springframework.web.servlet.View; SearchStrategy: all) found no beans (OnBeanCondition) WebSocketAutoConfiguration - required @ConditionalOnClass classes not found: org.springframework.web.socket.WebSocketHandler (OnClassCondition) java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:53) at java.lang.Thread.run(Thread.java:744) Caused by: org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.boot.context.embedded.EmbeddedServletContainerException: Unable to start embdedded Tomcat at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:138) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:476) at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:552) at org.springframework.boot.SpringApplication.run(SpringApplication.java:293) at org.springframework.boot.SpringApplication.run(SpringApplication.java:749) at org.springframework.boot.SpringApplication.run(SpringApplication.java:738) at hello.Application.main(Application.java:12) ... 6 more Caused by: org.springframework.boot.context.embedded.EmbeddedServletContainerException: Unable to start embdedded Tomcat at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.initialize(TomcatEmbeddedServletContainer.java:85) at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.<init>(TomcatEmbeddedServletContainer.java:53) at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getTomcatEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:259) at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:140) at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:158) at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:135) ... 13 more Caused by: java.lang.IllegalStateException: Tomcat connector in failed state at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.initialize(TomcatEmbeddedServletContainer.java:81) ... 18 more 

我想这是因为我的端口被使用了。 我的端口8080被使用,所以我尝试端口8181我没有应用程序的端口8181

在tomcat server.xml中,我将端口设置为8181,但问题仍然存在

我find这个职位:

当用Maven启动时,Tomcat的备用端口(不是8080)?

但启动后,我有同样的问题-vmaven.tomcat.port = 8181 tomcat:run-war

我不明白如何将maven链接到tomcat服务器这是我的pom.xml

 <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>org.springframework</groupId> <artifactId>gs-serving-web-content</artifactId> <version>0.1.0</version> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>0.5.0.M6</version> </parent> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.thymeleaf</groupId> <artifactId>thymeleaf-spring3</artifactId> </dependency> </dependencies> <properties> <start-class>hello.Application</start-class> </properties> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build> <repositories> <repository> <id>spring-milestone</id> <url>http://repo.spring.io/libs-milestone</url> <snapshots> <enabled>false</enabled> </snapshots> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>spring-milestone</id> <url>http://repo.spring.io/libs-milestone</url> <snapshots> <enabled>false</enabled> </snapshots> </pluginRepository> </pluginRepositories> </project> 

谢谢你的帮助

Spring Boot在默认情况下使用embedded式Tomcat,但是它不使用tomcat-maven-plugin而是以不同的方式处理它。 要更改端口,请使用--server.port参数,例如:

 java -jar target/gs-serving-web-content-0.1.0.jar --server.port=8181 

运行以下命令来search使用端口的进程

 lsof -i :<portNumber> | grep LISTEN 

在你的情况下,这将是 – >

 lsof -i :8080 | grep LISTEN java 78960 xyxss 119u IPv6 0x6c20d372bc88c27d 0t0 TCP *:8092 (LISTEN) 

78960是进程ID,使用下面的命令来终止进程

 kill -9 78960 

再次启动应用程序。

/src/main/resources/application.properties中configuration另一个端口号(例如:8181)

server.port = 8181

您需要在重新启动之前停止服务器。 查找红色框图标或服务器视图。

使用IntelliJ,我得到这个错误,当我试图运行一个spring的应用程序,而有一个应用程序已经运行。 我不得不停止第一个。 之后,运行第二个应用程序不会返回任何错误。

Spring Tool Suite的图像并停止应用程序按钮

在我看来,在服务器窗口中只显示了一个我从来没有用过这个项目的tomcat服务器。 我的SpringBoot项目使用了一个embedded式tomcat服务器,并且在我的应用程序完成时并没有停止。 我用红色箭头指示的这个button将停止应用程序和Tomcat服务器,所以下次运行应用程序时,我将不会收到Tomcat实例已经在端口8080上运行的错误。

实际的错误信息:

validation连接器的configuration,识别并停止在端口8080上侦听的任何进程,或将此应用程序configuration为侦听另一个端口。

导致:java.net.BindException:地址已经在使用中。 协议处理器启动失败

我现在正在研究closures完成我的SpringBoot Consuming Rest应用程序的所有服务的方法https://spring.io/guides/gs/consuming-rest/

春季启动

首先,检查谁使用端口8080。

  • telnet localhost 8080
  • 使用浏览器打开http:// localhost:8080

如果端口8080正在使用,请将侦听端口更改为8181。

如果你使用IDEA,修改启动configuration,运行 – >编辑configuration在这里input图像说明

如果使用mvn spring-boot,则使用以下命令:

 mvn spring-boot:run -Dserver.port=8181 

如果您使用java -jar,则使用以下命令:

 java -jar xxxx.jar --server.port=8181 

在我的情况下,Oracle TNS服务使用端口8080,发现使用运行命令“netstat – anob”作为pipe理员。 只需使用Windows开始菜单中的“closures数据库”即可停止该服务,并能够毫无问题地启动SpringBoot应用程序。

此外,如果你不能找出哪个应用程序使用8080端口,只是想运行SprintBoot应用程序,你可以点击运行为…并在VM参数input:-Dserver.port = 0(这将select任何随机可用的端口),或者你可以是特定的:-Dserver.port = 8081

希望能帮助到你。

我会build议杀死端口号。 它为我工作

 netstat -ano | findstr :yourPortNumber taskkill /PID typeyourPIDhere /F 

closures应用程序,然后在更改为新端口后重新启动它:

 ${port:8181} 

您可以使用任何新的未使用的端口。 在这里,我使用的端口8181。

我解决了这个问题,通过停止应用程序 (Eclipse中的红色方块),然后再次运行。 如果不停止,应用程序将保持运行模式,所以端口仍然使用。

你有另外一个在8080端口监听的进程,这是Spring Boot的web支持使用的默认端口。 您需要停止该进程或将您的应用configuration为在另一个端口上进行侦听。

您可以通过将server.port = 4040 (例如)添加到src / main / resources / application.properties来更改端口configuration

这只适用于我设置其他属性和使用可用的任意端口号,如下所示:

  • 阳明海运

/src/main/resources/application.yml

 server: port: 18181 management: port: 9191 tomcat: jvmroute: 5478 ajp: port: 4512 redirectPort: 1236 
  • 属性

/src/main/resources/application.properties

 server.port=18181 management.port=9191 tomcat.jvmroute=5478 tomcat.ajp.port=4512 tomcat.ajp.redirectPort=1236 

基本上默认的服务器通常运行在8080端口的后台。打开services.msc并停止tomcat服务器,然后再次运行spring启动应用程序。

在Eclipse中,如果安装了Spring Tool Suite,则可以转至启动仪表板并在浏览器中展开本地,然后右键单击在8080端口上运行的应用程序,然后在重新运行应用程序之前将其停止。