Currently I am using sudo ./gradlew clean build -x test
to build and nohup java -jar <jar file>
to run the main application in my ec2 console. And it runs successfully.
But when I am trying to run tests(annotated with @MicronautTest
) with sudo ./gradlew test
when the application is running on another port, it fails on every available port throwing this exception :
io.micronaut.http.server.exceptions.ServerStartupException: Unable to start Micronaut server on port: 4464
java.net.BindException: Address already in use
I am currently using micronaut.server.port: -1
in my application-test.yml
. But it does not seem to work.
Only time the test starts running when application server is not stopped, although the application server on runs on different fixed PORT number. Is this happening because my application is already running ?