Skip to content

Commit 8eb121a

Browse files
committed
fixed #478
1 parent 9f80dc9 commit 8eb121a

File tree

3 files changed

+29
-3
lines changed

3 files changed

+29
-3
lines changed

quick-start/src/main/java/com/marklogic/quickstart/ApplicationRunListener.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ public void contextLoaded(ConfigurableApplicationContext context) {}
2929
@Override
3030
public void finished(ConfigurableApplicationContext context, Throwable exception) {
3131
String port = context.getEnvironment().getProperty("local.server.port");
32-
System.out.println("QuickStart UI Ready and Listening on port " + port);
33-
System.out.println("http://localhost:" + port);
32+
if (exception == null) {
33+
System.out.println("QuickStart UI is Ready and Listening on port " + port + ".\n");
34+
System.out.println("Open your browser to http://localhost:" + port + ".\t(We recommend you use Chrome or FireFox.)");
35+
}
3436
}
3537
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package com.marklogic.quickstart;
2+
3+
import org.springframework.boot.context.embedded.tomcat.ConnectorStartFailedException;
4+
import org.springframework.boot.diagnostics.AbstractFailureAnalyzer;
5+
import org.springframework.boot.diagnostics.FailureAnalysis;
6+
7+
public class PortInUseFailureAnalyzer extends AbstractFailureAnalyzer<ConnectorStartFailedException> {
8+
@Override
9+
protected FailureAnalysis analyze(Throwable rootFailure,
10+
ConnectorStartFailedException cause) {
11+
return new FailureAnalysis(
12+
"QuickStart failed to start because port " + cause.getPort()
13+
+ " is already being used.",
14+
"Try running with a different port:\n "
15+
+ "java -jar quickstart.war --server.port=8080\t\t(replace 8080 with your desired port)",
16+
cause);
17+
}
18+
}
Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
1-
org.springframework.boot.SpringApplicationRunListener=com.marklogic.quickstart.ApplicationRunListener
1+
# Run Liseners
2+
org.springframework.boot.SpringApplicationRunListener=\
3+
com.marklogic.quickstart.ApplicationRunListener
4+
5+
# Failure Analyzers
6+
org.springframework.boot.diagnostics.FailureAnalyzer=\
7+
com.marklogic.quickstart.PortInUseFailureAnalyzer

0 commit comments

Comments
 (0)