I am trying to call webAPI from gradle project.
My build.gradle is as following.
plugins {
id 'org.springframework.boot' version '2.1.4.RELEASE'
id 'java'
}
apply plugin: 'io.spring.dependency-management'
dependencies {
implementation 'org.springframework.boot:spring-boot-starter'
runtimeOnly 'org.springframework.boot:spring-boot-devtools'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
compile 'org.springframework.boot:spring-boot-starter-webflux'
compile 'org.projectreactor:reactor-spring:1.0.1.RELEASE'
}
If I remove following dependency
compile 'org.springframework.boot:spring-boot-starter-webflux'
It works, but if I add it back. it gives error as
Web server failed to start. Port 8080 was already in use.
So, how do I fix this, so that I can use webclient? Because application is not web application which requires port to run. it is a sort of microservice.
I just want to use WebClient of Spring Boot. How do i use it without converting my application into web application.
1) On the top right corner of your console, there is a red button, to stop the spring boot application which is already running on this port just click on the red button to terminate. 2) If the red button is not activated you need to right click on the console and select terminate/disconnect all. Hope this helps.
Answers 10 : of Deployment error:Starting of Tomcat failed, the server port 8080 is already in use. Change your Tomcat port address to 8084 and Shut Down Port to 8025. This will resolve your problem.
If on windows and your getting this every time you run the application you need to keep doing:
> netstat -ano | findstr *<port used>* TCP 0.0.0.0:*<port used>* 0.0.0.0:0 LISTENING *<pid>* TCP [::]:*<port used>* [::]:0 LISTENING *<pid>* > taskkill /F /PID *<pid>* SUCCESS: The process with PID *<pid>* has been terminated.
If netstat above includes something like this;
TCP [zzzz:e2ce:44xx:1:axx6:dxxf:xxx:xxxx]:540yy [zzzz:e2ce:44xx:1:axx6:dxxf:xxx:xxxx]:*<port used>* TIME_WAIT 0
Then you can either wait for a little while or reconfigure to use another port.
I suppose we could write some code to randomly generate and check if a port is free when the application runs. Though this will have diminishing returns as they start to get used up. On the other hand could add a resource clean up code that does what we have above once the application stops.
If you don't want the embedded server to start, just set the following property in you application.properties
(or .yml
):
spring.main.web-application-type=none
If your classpath contains the necessary bits to start a web server, Spring Boot will automatically start it. To disable this behaviour configure the WebApplicationType in your application.properties
Source: https://docs.spring.io/spring-boot/docs/current/reference/html/howto-embedded-web-servers.html
If you application really is a Web application, then you can easily change the port using the server.port
property (in your application's .properties
/.yaml
file, as a command line argument at startup, etc).
You can change the default port of your application in application.properties by adding the following line:
server.port = 8090
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With