2
respostas

Falha no MVN Package.

Executei o MVN package e não funcionou. Observe o erro abaixo que apresenta.


SQL State : 08001
Error Code : 0
Message : Connection to localhost:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.

Caused by: org.postgresql.util.PSQLException: Connection to localhost:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
Caused by: java.net.ConnectException: Connection refused (Connection refused)

[INFO] Running br.com.caelum.clines.api.users.UserFormMapperTest
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.003 s - in br.com.caelum.clines.api.users.UserFormMapperTest
[INFO] Running br.com.caelum.clines.api.users.UserViewMapperTest
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.001 s - in br.com.caelum.clines.api.users.UserViewMapperTest
[INFO] Running br.com.caelum.clines.shared.domain.FlightTest
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.001 s - in br.com.caelum.clines.shared.domain.FlightTest
[INFO]
[INFO] Results:
[INFO]
[ERROR] Errors:
[ERROR] AircraftControllerTest.shouldReturn404WhenNotExistAircraftByCode » IllegalState
[ERROR] AircraftControllerTest.shouldReturnAnAircraftByCode » IllegalState Failed to l...
[ERROR] AircraftRepositoryTest.shouldReturnAircraftByCodeWhenExistsAnAircraftInDB » IllegalState
[ERROR] AircraftRepositoryTest.shouldReturnAnEmptyOptionalWhenNotExistsAircraftByCode » IllegalState
[ERROR] AircraftRepositoryTest.shouldSaveANewAircraft » IllegalState Failed to load Ap...
[ERROR] LocationControllerIntegrationTest.listAllLocationsShouldReturnAnEmptyList » IllegalState
[ERROR] LocationControllerIntegrationTest.listAllLocationsShouldReturnListOfLocations » IllegalState
[ERROR] LocationControllerIntegrationTest.shouldReturnHttpStatus201AndHeaderAttributeLocationWhenValidFormIsInformed » IllegalState
[ERROR] LocationControllerIntegrationTest.shouldReturnLocationById » IllegalState Fail...
[ERROR] LocationControllerIntegrationTest.shouldReturnNotFoundForNotFoundLocation » IllegalState
[ERROR] PromotionalCodeControllerTest.shouldReturnHttpStatus201AndHeaderAttributeLocationWhenValidFormIsInformed » IllegalState
[ERROR] PromotionalCodeControllerTest.shouldReturnHttpStatus409IfCodeAlreadyExists » IllegalState
[ERROR] PromotionalCodeRepositoryTest.shouldSaveNewPromotionalCode » IllegalState Fail...
[ERROR] UserControllerTest.shouldReturn404WhenNotExistUserById » IllegalState Failed t...
[ERROR] UserControllerTest.shouldReturnAnUserById » IllegalState Failed to load Applic...
[INFO]
[ERROR] Tests run: 49, Failures: 0, Errors: 15, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 05:17 min
[INFO] Finished at: 2025-11-18T00:32:04-03:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.2:test (default-test) on project clines-api: There are test failures.
[ERROR]
[ERROR] Please refer to /mnt/c/1.projetos/agilidade e devops/target/surefire-reports for the individual test results.
[ERROR] Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
Wesbonf@Devops:/mnt/c/1.projetos/agilidade e devops$

Matricule-se agora e aproveite até 50% OFF

O maior desconto do ano para você evoluir com a maior escola de tecnologia

QUERO APROVEITAR
2 respostas

Insira aqui a descrição dessa imagem para ajudar na acessibilidade

Oi Wesley! Como vai?

Pelo erro que você está enfrentando, parece que o Maven não está conseguindo se conectar ao banco de dados PostgreSQL. Isso pode estar acontecendo por alguns motivos, e aqui estão algumas sugestões para resolver o problema:

  1. Verifique as configurações de conexão: Confirme se o hostname e a porta estão corretos no arquivo de configuração da sua aplicação (geralmente application.properties ou application.yml). O erro indica que está tentando conectar em localhost:5432, então verifique se essa é realmente a configuração correta.

  2. Docker e Containers: Como você está usando Docker, certifique-se de que o container do PostgreSQL está rodando e que a aplicação pode se conectar a ele. Você pode precisar verificar a rede do Docker para garantir que os containers possam se comunicar.

  3. Logs do PostgreSQL: Verifique os logs do contêiner do PostgreSQL para ver se há alguma mensagem de erro que possa ajudar a identificar o problema.

Espero que essas dicas ajudem a resolver o problema que você está enfrentando. Bons estudos!

Caso este post tenha lhe ajudado, por favor, marcar como solucionado ✓.