我可以使用mvn spring-boot
成功启动spring-boot,documentation提及优雅地退出应用程序点击ctrl-c
。
Terminate batch job (Y/N)? Y
maven进程终止,但Tomcat仍在运行,我仍然可以访问网页。当我尝试再次启动spring-boot时,它无法启动Tomcat,因为端口正在使用中。
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.1.0.BUILD-SNAPSHOT)
2014-05-02 12:13:57.666 INFO 6568 --- [ main] Example : Starting Example on challenger with PID 6568 (E:\workspace\SpringBoot\target\cla
sses started by steven in E:\workspace\SpringBoot)
2014-05-02 12:13:57.707 INFO 6568 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWeb
ApplicationContext@11ecab7c: startup date [Fri May 02 12:13:57 EDT 2014]; root of context hierarchy
2014-05-02 12:13:58.097 INFO 6568 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Overriding bean definition for bean 'beanNameViewResolver': replacing [Root bean
: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfi
gure.web.ErrorMvcAutoConfiguration$WhitelabelErrorViewConfiguration; factoryMethodName=beanNameViewResolver; initMethodName=null; destroyMethodName=(inferred); defined in class pat
h resource [org/springframework/boot/autoconfigure/web/ErrorMvcAutoConfiguration$WhitelabelErrorViewConfiguration.class]] with [Root bean: class [null]; scope=; abstract=false; laz
yInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$WebMvcAuto
ConfigurationAdapter; factoryMethodName=beanNameViewResolver; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfig
ure/web/WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter.class]]
2014-05-02 12:13:58.682 INFO 6568 --- [ main] .t.TomcatEmbeddedServletContainerFactory : Server initialized with port: 8080
2014-05-02 12:13:58.892 INFO 6568 --- [ main] o.apache.catalina.core.StandardService : Starting service Tomcat
2014-05-02 12:13:58.892 INFO 6568 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/7.0.53
2014-05-02 12:13:58.981 INFO 6568 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2014-05-02 12:13:58.981 INFO 6568 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1277 ms
2014-05-02 12:13:59.453 INFO 6568 --- [ost-startStop-1] o.s.b.c.e.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
2014-05-02 12:13:59.455 INFO 6568 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2014-05-02 12:13:59.570 ERROR 6568 --- [ main] o.a.coyote.http11.Http11NioProtocol : Failed to start end point associated with ProtocolHandler ["http-nio-8080"]
java.net.BindException: Address already in use: bind
at sun.nio.ch.Net.bind0(Native Method)
at sun.nio.ch.Net.bind(Net.java:344)
at sun.nio.ch.Net.bind(Net.java:336)
at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:199)
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:647)
at org.apache.coyote.AbstractProtocol.start(AbstractProtocol.java:449)
at org.apache.catalina.connector.Connector.startInternal(Connector.java:1007)
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:731)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.startup.Tomcat.start(Tomcat.java:341)
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.initialize(TomcatEmbeddedServletContainer.java:79)
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.<init>(TomcatEmbeddedServletContainer.java:69)
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getTomcatEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:270)
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:145)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:159)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:132)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:476)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:120)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:680)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:313)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:941)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:930)
at Example.main(Example.java:16)
2014-05-02 12:13:59.571 ERROR 6568 --- [ 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:731)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.startup.Tomcat.start(Tomcat.java:341)
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.initialize(TomcatEmbeddedServletContainer.java:79)
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.<init>(TomcatEmbeddedServletContainer.java:69)
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getTomcatEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:270)
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:145)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:159)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:132)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:476)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:120)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:680)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:313)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:941)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:930)
at Example.main(Example.java:16)
Caused by: org.apache.catalina.LifecycleException: service.getName(): "Tomcat"; Protocol handler start failed
at org.apache.catalina.connector.Connector.startInternal(Connector.java:1014)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 18 common frames omitted
Caused by: java.net.BindException: Address already in use: bind
at sun.nio.ch.Net.bind0(Native Method)
at sun.nio.ch.Net.bind(Net.java:344)
at sun.nio.ch.Net.bind(Net.java:336)
at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:199)
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:647)
at org.apache.coyote.AbstractProtocol.start(AbstractProtocol.java:449)
at org.apache.catalina.connector.Connector.startInternal(Connector.java:1007)
... 19 common frames omitted
2014-05-02 12:13:59.572 INFO 6568 --- [ main] o.apache.catalina.core.StandardService : Stopping service Tomcat
2014-05-02 12:13:59.580 INFO 6568 --- [ main] .b.l.ClasspathLoggingApplicationListener : Application failed to start with classpath: [file:/E:/workspace/SpringBoot/src/m
ain/resources, file:/E:/workspace/SpringBoot/src/main/resources, file:/E:/workspace/SpringBoot/target/classes/, file:/C:/Users/steven/.m2/repository/org/springframework/boot/spring
-boot-starter-web/1.1.0.BUILD-SNAPSHOT/spring-boot-starter-web-1.1.0.BUILD-SNAPSHOT.jar, file:/C:/Users/steven/.m2/repository/org/springframework/boot/spring-boot-starter/1.1.0.BUI
LD-SNAPSHOT/spring-boot-starter-1.1.0.BUILD-SNAPSHOT.jar, file:/C:/Users/steven/.m2/repository/org/springframework/boot/spring-boot/1.1.0.BUILD-SNAPSHOT/spring-boot-1.1.0.BUILD-SNA
PSHOT.jar, file:/C:/Users/steven/.m2/repository/org/springframework/boot/spring-boot-autoconfigure/1.1.0.BUILD-SNAPSHOT/spring-boot-autoconfigure-1.1.0.BUILD-SNAPSHOT.jar, file:/C:
/Users/steven/.m2/repository/org/springframework/boot/spring-boot-starter-logging/1.1.0.BUILD-SNAPSHOT/spring-boot-starter-logging-1.1.0.BUILD-SNAPSHOT.jar, file:/C:/Users/steven/.
m2/repository/org/slf4j/jcl-over-slf4j/1.7.7/jcl-over-slf4j-1.7.7.jar, file:/C:/Users/steven/.m2/repository/org/slf4j/slf4j-api/1.7.7/slf4j-api-1.7.7.jar, file:/C:/Users/steven/.m2
/repository/org/slf4j/jul-to-slf4j/1.7.7/jul-to-slf4j-1.7.7.jar, file:/C:/Users/steven/.m2/repository/org/slf4j/log4j-over-slf4j/1.7.7/log4j-over-slf4j-1.7.7.jar, file:/C:/Users/st
even/.m2/repository/ch/qos/logback/logback-classic/1.1.2/logback-classic-1.1.2.jar, file:/C:/Users/steven/.m2/repository/ch/qos/logback/logback-core/1.1.2/logback-core-1.1.2.jar, f
ile:/C:/Users/steven/.m2/repository/org/yaml/snakeyaml/1.13/snakeyaml-1.13.jar, file:/C:/Users/steven/.m2/repository/org/springframework/boot/spring-boot-starter-tomcat/1.1.0.BUILD
-SNAPSHOT/spring-boot-starter-tomcat-1.1.0.BUILD-SNAPSHOT.jar, file:/C:/Users/steven/.m2/repository/org/apache/tomcat/embed/tomcat-embed-core/7.0.53/tomcat-embed-core-7.0.53.jar, f
ile:/C:/Users/steven/.m2/repository/org/apache/tomcat/embed/tomcat-embed-el/7.0.53/tomcat-embed-el-7.0.53.jar, file:/C:/Users/steven/.m2/repository/org/apache/tomcat/embed/tomcat-e
mbed-logging-juli/7.0.53/tomcat-embed-logging-juli-7.0.53.jar, file:/C:/Users/steven/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.3.3/jackson-databind-2.3.3.jar, fi
le:/C:/Users/steven/.m2/repository/com/fasterxml/jackson/core/jackson-annotations/2.3.0/jackson-annotations-2.3.0.jar, file:/C:/Users/steven/.m2/repository/com/fasterxml/jackson/co
re/jackson-core/2.3.3/jackson-core-2.3.3.jar, file:/C:/Users/steven/.m2/repository/org/springframework/spring-web/4.0.3.RELEASE/spring-web-4.0.3.RELEASE.jar, file:/C:/Users/steven/
.m2/repository/org/springframework/spring-aop/4.0.3.RELEASE/spring-aop-4.0.3.RELEASE.jar, file:/C:/Users/steven/.m2/repository/aopalliance/aopalliance/1.0/aopalliance-1.0.jar, file
:/C:/Users/steven/.m2/repository/org/springframework/spring-beans/4.0.3.RELEASE/spring-beans-4.0.3.RELEASE.jar, file:/C:/Users/steven/.m2/repository/org/springframework/spring-cont
ext/4.0.3.RELEASE/spring-context-4.0.3.RELEASE.jar, file:/C:/Users/steven/.m2/repository/org/springframework/spring-core/4.0.3.RELEASE/spring-core-4.0.3.RELEASE.jar, file:/C:/Users
/steven/.m2/repository/org/springframework/spring-webmvc/4.0.3.RELEASE/spring-webmvc-4.0.3.RELEASE.jar, file:/C:/Users/steven/.m2/repository/org/springframework/spring-expression/4
.0.3.RELEASE/spring-expression-4.0.3.RELEASE.jar]
Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.boot.context.embedde
d.EmbeddedServletContainerException: Unable to start embedded Tomcat
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:135)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:476)
[INFO] ------------------------------------------------------------------------
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:120)
[INFO] BUILD SUCCESS
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:680)
[INFO] ------------------------------------------------------------------------
at org.springframework.boot.SpringApplication.run(SpringApplication.java:313)
[INFO] Total time: 4.653 s
at org.springframework.boot.SpringApplication.run(SpringApplication.java:941)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:930)
at Example.main(Example.java:16)
Caused by: org.springframework.boot.context.embedded.EmbeddedServletContainerException: Unable to start embedded Tomcat
[INFO] Finished at: 2014-05-02T12:13:59-05:00
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.initialize(TomcatEmbeddedServletContainer.java:106)
[INFO] Final Memory: 16M/232M
[INFO] ------------------------------------------------------------------------
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.<init>(TomcatEmbeddedServletContainer.java:69)
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getTomcatEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:270)
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:145)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:159)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:132)
... 7 more
Caused by: java.lang.IllegalStateException: Tomcat connector in failed state
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.initialize(TomcatEmbeddedServletContainer.java:102)
... 12 more
要继续,我必须手动终止正在运行的进程。这是一个错误还是我错过了什么?
答案 0 :(得分:65)
在Windows 7上运行的1.1.9版本上仍然会出现这种情况。
所以按下Ctrl C. 杀死后台java的最快方法是。
找到java PID
c:\>netstat -ano | find "8080"
TCP 0.0.0.0:8080 0.0.0.0:0 LISTENING 1196
TCP [::]:8080 [::]:0 LISTENING 1196
c:\>taskkill /F /PID 1196
SUCCESS: The process with PID 1196 has been terminated.
我假设你在上面的例子中运行了http端口8080
答案 1 :(得分:21)
以下是我在Mac上所做的事情:
kill `lsof -i -n -P | grep TCP | grep 8080 | tr -s " " "\n" | sed -n 2p`
它使用8080找到PID并将其杀死。
答案 2 :(得分:5)
编辑: 在ubuntu中,使用命令:
fuser -k 8080/tcp
杀死进程。我使用spring-boot 1.3.0-Build-snapshot,问题仍然存在。我的SO是Ubuntu,问题发生在从Eclipse运行或从控制台运行。关于这个问题的讨论是here。这似乎是spring-boot库的一个问题,至少关于tomcat库。我也在这个修复线上。不幸的是,这是我们在尝试使用尖端技术直到成熟之前所付出的代价。
答案 3 :(得分:2)
在IDEA中,您必须再次运行之前停止处理。该命令将关闭嵌入式Tomcat。
答案 4 :(得分:2)
我知道我来不及回答,但也许有人可以帮忙解决这个问题。 STS用户可以使用Relaunch
按钮而不是Run
来确保关闭任何现有实例
供参考:
https://docs.spring.io/spring-boot/docs/current/reference/html/using-boot-running-your-application.html
答案 5 :(得分:2)
对于那些使用Eclipse的人来说,这是迄今为止最好的答案:
打开“运行配置”,编辑为项目定义的maven启动,然后在“JRE”选项卡下,将 -Dfork = false 添加到VM参数文本区域。
然后当您点击红色停止按钮时,tomcat服务器将停止并且您的端口将被释放。
答案 6 :(得分:1)
这只发生在Windows中。 https://github.com/spring-projects/spring-boot/issues/773
更新:现在应该修复。
答案 7 :(得分:1)
我遇到了同样的问题,但是有一种更好,更简单的方式来运行没有此问题的Spring Boot应用。
运行方式-> Java应用程序
更新: 此外,如果您使用Spring STS(可用于VS Code,IntelliJ,Eclipse等),则有机会从Boot Dashboard管理您的应用程序。真的很有用。
答案 8 :(得分:0)
我在Windows 10中遇到了同样的问题,当时我在Cygwin终端中运行mvn spring-boot:run
。我什至无法使用ps -ef
在Cygwin中找到Tomcat进程。我必须使用netstat -ao
在PowerShell中搜索该过程。
在PowerShell中使用mvn spring-boot:run
对我来说很好。
答案 9 :(得分:0)
我们可以从月食console
视图中杀死该tomcat实例,方法是单击“停止”(红色正方形图标)按钮和运行图标旁边的红色按钮,再次运行spring boot应用程序。
答案 10 :(得分:0)
对于Powershell,将以下代码放在以'.ps1'结尾的文件中
$processes = (get-NetTCPConnection| ? {$_.LocalPort -eq "8080"}).OwningProcess
foreach ($process in $processes) {Get-Process -PID $process | Stop-Process -Force}
答案 11 :(得分:0)
是的,这是正确的,当您使用spring-boot-run进行maven安装时,并且在应用程序停止后,tomcat端口仍会侦听。
我为那些正在使用此端口/地址的用户提供了屏幕截图。 您需要做的是再次运行spring boot应用程序之前,只需转到Windows任务管理器并结束名为“ Java(TM)Platform SE binary”的进程,然后运行启动应用程序,您的端口将没有该进程,您不会再出现此问题。(第一次运行后,您不必这样做) 它为我创造了奇迹。希望对您有帮助
答案 12 :(得分:0)
答案 13 :(得分:0)
这个解决方案适用于我的Spring Boot v1.x现在可以使用v2.x:
hangingJavaProcessToStop=`jps | grep Application | awk '{print $1}'`
echo "hangingJavaProcessToStop: $hangingJavaProcessToStop"
kill -9 $hangingJavaProcessToStop
通过这种方式,您可以专门杀死Spring Boot的Application
Java进程,而不是一次性杀死所有Java进程。我假设如果您的Spring Boot“Application”(包含类的main
方法)的调用方式不同,则必须使用其名称而不是Application
。
我正在使用 WSL / Debian 在我的 Windows 计算机上运行上面的代码段。我没有使用PowerShell或Windows命令行。
答案 14 :(得分:0)
通过调用导致关机
curl -v -X POST http://127.0.0.1:8091/shutdown
为您提供了正确配置的spring-boot。
要支持此功能,您必须更新应用程序属性。这部分在https://stackoverflow.com/a/26563344/58794中描述。
通过添加:
来更新application.ymlmanagement:
security:
enabled: false
endpoints:
shutdown:
enabled: true
或通过添加:
来更新application.propertiesmanagement.security.enabled=false
endpoints.shutdown.enabled=true
一旦被召唤
$ curl -v -X POST http://127.0.0.1:8091/shutdown
* STATE: INIT => CONNECT handle 0x600057990; line 1423 (connection #-5000)
* Added connection 0. The cache now contains 1 members
* Trying 127.0.0.1...
* TCP_NODELAY set
* STATE: CONNECT => WAITCONNECT handle 0x600057990; line 1475 (connection #0)
* Connected to 127.0.0.1 (127.0.0.1) port 8091 (#0)
* STATE: WAITCONNECT => SENDPROTOCONNECT handle 0x600057990; line 1592 (connection #0)
* Marked for [keep alive]: HTTP default
* STATE: SENDPROTOCONNECT => DO handle 0x600057990; line 1610 (connection #0)
> POST /shutdown HTTP/1.1
> Host: 127.0.0.1:8091
> User-Agent: curl/7.56.1
> Accept: */*
>
* STATE: DO => DO_DONE handle 0x600057990; line 1689 (connection #0)
* STATE: DO_DONE => WAITPERFORM handle 0x600057990; line 1814 (connection #0)
* STATE: WAITPERFORM => PERFORM handle 0x600057990; line 1824 (connection #0)
* HTTP 1.1 or later with persistent connection, pipelining supported
< HTTP/1.1 200
< X-Application-Context: application:h2:8091
< Content-Type: application/vnd.spring-boot.actuator.v1+json;charset=UTF-8
< Transfer-Encoding: chunked
< Date: Fri, 22 Dec 2017 07:01:04 GMT
<
* STATE: PERFORM => DONE handle 0x600057990; line 1993 (connection #0)
* multi_done
* Connection #0 to host 127.0.0.1 left intact
* Expire cleared
{"message":"Shutting down, bye..."}
容器将关闭
o.s.c.support.DefaultLifecycleProcessor : Stopping beans in phase 0
o.s.j.e.a.AnnotationMBeanExporter : Unregistering JMX-exposed beans on shutdown
j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
但如果您从mvn spring-boot:run
发起,则可能会获得:
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 35.613 s
[INFO] Finished at: 2017-12-22T02:01:05-05:00
[INFO] Final Memory: 25M/577M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:1.5.7.RELEASE:run (default-cli) on project PROJECTNAME: Could not exec java: Application finished with exit code: 1 -> [Help 1]
如果您没有management.security.enabled=false
,可能会出现以下错误:
$ curl -v -X POST http://127.0.0.1:8091/shutdown
> POST /shutdown HTTP/1.1
> Host: 127.0.0.1:8091
> User-Agent: curl/7.56.1
> Accept: */*
>
< HTTP/1.1 401
< X-Application-Context: application:h2:8091
< Content-Type: application/vnd.spring-boot.actuator.v1+json;charset=UTF-8
< Transfer-Encoding: chunked
< Date: Fri, 22 Dec 2017 06:56:19 GMT
<
{"timestamp":1513925779265,"status":401,"error":"Unauthorized","message":"Full authentication is required to access this resource.","path":"/shutdown"}
如果您没有endpoints.shutdown.enabled=true
,您会看到:
$ curl -v -X POST http://127.0.0.1:8091/shutdown
> POST /shutdown HTTP/1.1
> Host: 127.0.0.1:8091
> User-Agent: curl/7.56.1
> Accept: */*
>
< HTTP/1.1 404
< X-Application-Context: application:h2:8091
< Content-Type: application/json;charset=UTF-8
< Transfer-Encoding: chunked
< Date: Fri, 22 Dec 2017 06:58:52 GMT
<
{"timestamp":1513925932345,"status":404,"error":"Not Found","message":"No message available","path":"/shutdown"}
如果您尝试使用GET而不是POST,则会显示以下错误:
$ curl -v http://127.0.0.1:8091/shutdown
> GET /shutdown HTTP/1.1
> Host: 127.0.0.1:8091
> User-Agent: curl/7.56.1
> Accept: */*
>
< HTTP/1.1 405
< X-Application-Context: application:h2:8091
< Allow: POST
< Content-Type: application/json;charset=UTF-8
< Transfer-Encoding: chunked
< Date: Fri, 22 Dec 2017 06:54:12 GMT
<
{"timestamp":1513925652827,"status":405,"error":"Method Not Allowed","exception":"org.springframework.web.HttpRequestMethodNotSupportedException","message":"Request method 'GET' not supported","path":"/shutdown"}
答案 15 :(得分:0)
我在Mac上的eclipse中遇到了运行SpringBoot应用程序的相同问题。我手动必须使用8080找到所有PID并杀死它们。但是,幸运的是,我意识到我们可以直接从日食&#34;控制台&#34;中删除该tomcat实例。通过点击停止(红色方块图标)按钮并再次运行弹簧启动应用程序来查看。
答案 16 :(得分:0)
从Mac上的netbeans 8.1运行spring boot app时遇到了这个问题。当我在netbeans中点击红色方块按钮时,java进程没有终止,所以当我重新启动应用程序时,我总是得到“绑定异常,地址已经在使用”的东西。这是已知的错误。
解决方案是 add spring-boot:run命令运行项目的目标...
...而且如果你在当前项目和插件组中找到“没有找到前缀'spring-boot'的插件”,你可能需要将它添加到依赖项:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.5.RELEASE</version>
</parent>
<repositories>
<repository>
<id>spring-releases</id>
<url>https://repo.spring.io/libs-release</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-releases</id>
<url>https://repo.spring.io/libs-release</url>
</pluginRepository>
</pluginRepositories>
答案 17 :(得分:-3)
按顺序键入以下命令。
$ ps -ef | grep -i java
$ kill -9 3361