question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Fails to start when using @SpringBootApplication with SpringApplicationBuilder.sources

See original GitHub issue

use @SpringBootApplication with SpringApplicationBuilder,my app starts failed

// main method
new SpringApplicationBuilder()
                .sources(ParentConfig.class)
                .child(Child1Config.class)
                .sibling(Child2Config.class)
                .banner(new AppBanner())
                .logStartupInfo(false)
                .run(args);
// ParentConfig
@SpringBootApplication
@PropertySource("classpath:/parent.properties")
public class ParentConfig {
}
// Child1Config 
@SpringBootApplication
@PropertySource("classpath:/child1.properties")
public class Child1Config {

}
// Child2Config 
@SpringBootApplication
@PropertySource("classpath:/child2.properties")
public class Child2Config {

}

the error log as follow:

Description:

The Tomcat connector configured to listen on port 8080 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 8080, or configure this application to listen on another port.

2018-02-26 14:30:41.239  INFO 33664 --- [           main] ConfigServletWebServerApplicationContext : Closing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@109f5dd8: startup date [Mon Feb 26 14:30:39 CST 2018]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@a4102b8
2018-02-26 14:30:41.242  INFO 33664 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Unregistering JMX-exposed beans on shutdown

the version of springboot is “2.0.0.RC2” or “2.0.0.BUILD-SNAPSHOT”

but if i change the version to “1.5.10.RELEASE”, it work fine. Another solutation is change the @SpringBootApplication to @Configuration in ParentConfig.java.

I don’t know why, can anyone tell me? Thank you very much!!!

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

5reactions
rsb-techcommented, Jul 8, 2018

I have also faced the same issue, to overcome this issue you can kill the PID using following commands.

C:\Users\Admin> netstat -ano | findstr :8080

It will show as below:

  TCP    0.0.0.0:8080           0.0.0.0:0              LISTENING       6956
  TCP    [::]:8080              [::]:0                 LISTENING       6956

Then run the below command to kill the PID

C:\Users\Admin>taskkill /PID 6956 /F
SUCCESS: The process with PID 6956 has been terminated.

Now you can re run the Spring application smoothly. Thank you!!

0reactions
Kamalesh-147commented, Jun 25, 2019

Run the command with the port used : example : lsof -i : 8080(Port number)

Now kill the process. command -: kill -9 <PID> (example : kill -9 8080).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Spring boot application fails to start - Stack Overflow
I have a Spring Boot Web Application that fails to start with the following error. It's a client application that discovers Eureka server....
Read more >
Spring Boot Error ApplicationContextException - Baeldung
The simple solution to fix our error would be to annotate our MainEntryPoint class with the @SpringBootApplication annotation. By using this ...
Read more >
SpringApplicationBuilder (Spring Boot 3.0.0 API)
Creates a new SpringApplication instance from the given sources using the given ResourceLoader . SpringApplicationBuilder. environment(ConfigurableEnvironment ...
Read more >
Spring Boot - SpringApplicationBuilder Class Example
Testing Spring Boot Application with JUnit and Mockito ... We turn off the banner and the startup information using SpringApplicationBuilder class APIs:.
Read more >
java.lang.nosuchmethoderror: org.springframework.boot.builder ...
Now i have created discovery server, using start.spring.io by adding ... Reposted from GitHub: Spring Boot Application fails to start with error "java.lang....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found