Solucionado (ver solução)
Solucionado
(ver solução)
5
respostas

Erro ao gerar o Builder

Ola fiz a configuração aqui pelo Eclipse:

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

-DRESTAURANTES_JWT_SECRET=123456
-DRESTAURANTES_DATABASE_URL=jdbc:mysql://localhost:3306/restaurantes?useTimezone=true&serverTimezone=UTC
-DRESTAURANTES_DATABASE_USERNAME=root
-DRESTAURANTES_DATABASE_PASSWORD=root

Esta dando este erro: Começou a dar erro no teste, mas antes de criar as variáveis de ambiente estava passando certinho:

[INFO] Total time:  11.374 s
[INFO] Finished at: 2022-06-21T15:08:11-03:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.1:test (default-test) on project restaurantes: There are test failures.
[ERROR] 
[ERROR] Please refer to C:\Workspace\ProjetoRestaurantes\FontesRestaurantes\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

Eu não criei a properties Prod, deixei como default, e muda para Application-teste.properties somente na área de teste, usando a anotação para forçar o test.

# datasource url: jdbc:mysql://localhost:3306/restaurantes?useTimezone=true&serverTimezone=UTC
spring.datasource.url=${RESTAURANTES_DATABASE_URL}
spring.datasource.username=${RESTAURANTES_DATABASE_USERNAME}
spring.datasource.password=${RESTAURANTES_DATABASE_PASSWORD}
spring.datasource.testWhileIdle=true
spring.datasource.validationQuery=SELECT 1
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver

spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=update

spring.jpa.hibernate.naming-strategy=org.hibernate.cfg.ImproveNamingStrategy
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL8Dialect

# jwt A+X;fTJP&Pd,TD9dwVq(hsHX,ya^<wsD_UK7L+@=S;{'CydP]{v@}G'b>et;yz$*\yL5S8EJN:%P:X%H9>#nYLrX}@\s?CQcpspH,2emzBc!Q[V'AYa~uzF8WR~AUrMzxp/V$9([S9X#zj/CH('#]B_Hc+%fGhe27YB;^j4\Xk=Ju"Ap~_&<L;=!Z;!,2UP;!hF3P]j85#*`&T]/kB/W^6$v~u6qpejL>kY^f)sy4:qTq_Ec!-z!@aAp~sLKGU>$
forum.jwt.secret=${RESTAURANTES_JWT_SECRET}
forum.jwt.expiration=86400000

# actuator
management.endpoint.health.show-details=always
management.endpoints.web.exposure.include=*
info.app.name=@project.name@
info.app.version=@project.version@

# spring boot admin server
spring.boot.admin.client.url=http://localhost:8081
5 respostas
solução!

Oi Jefferson,

Pelo erro tem testes que estão falhando: [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.1:test (default-test) on project restaurantes: There are test failures.

Então precisa ver no log completo quais testes falharam para entender o porquê.

Sim pode ser que a variavel de ambiente tenha causado um erro, quando retiro as variaveis de ambiente, da certinho: [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 17.076 s [INFO] Finished at: 2022-06-21T15:36:22-03:00 [INFO] ------------------------------------------------------------------------

Meu arquivo application.properties deixei no Default,

# datasource
spring.datasource.url=${DATABASE_URL}
spring.datasource.username=${DATABASE_USERNAME}
spring.datasource.password=${DATABASE_PASSWORD}

spring.datasource.testWhileIdle=true
spring.datasource.validationQuery=SELECT 1
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver

spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=update

spring.jpa.hibernate.naming-strategy=org.hibernate.cfg.ImproveNamingStrategy
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL8Dialect

# jwt
forum.jwt.secret=A+X;fTJP&Pd,TD9dwVq(hsHX,ya^<wsD_UK7L+@=S;{'CydP]{v@}G'b>et;yz$*\yL5S8EJN:%P:X%H9>#nYLrX}@\s?CQcpspH,2emzBc!Q[V'AYa~uzF8WR~AUrMzxp/V$9([S9X#zj/CH('#]B_Hc+%fGhe27YB;^j4\Xk=Ju"Ap~_&<L;=!Z;!,2UP;!hF3P]j85#*`&T]/kB/W^6$v~u6qpejL>kY^f)sy4:qTq_Ec!-z!@aAp~sLKGU>$
forum.jwt.expiration=86400000

# actuator
management.endpoint.health.show-details=always
management.endpoints.web.exposure.include=*
info.app.name=@project.name@
info.app.version=@project.version@

# spring boot admin server
spring.boot.admin.client.url=http://localhost:8081

Deu certo agora professor, era o código criptografado da variável JWT_SECRET,

A+X;fTJP&Pd,TD9dwVq(hsHX,ya^<wsD_UK7L+@=S;{'CydP]{v@}G'b>et;yz$*\yL5S8EJN:%P:X%H9>#nYLrX}@\s?CQcpspH,2emzBc!Q[V'AYa~uzF8WR~AUrMzxp/V$9([S9X#zj/CH('#]B_Hc+%fGhe27YB;^j4\Xk=Ju"Ap~_&<L;=!Z;!,2UP;!hF3P]j85#*`&T]/kB/W^6$v~u6qpejL>kY^f)sy4:qTq_Ec!-z!@aAp~sLKGU>$

eu mantive este campo na properties, e deu certo: Acho que ele se perdeu entre caracteres especiais.

Ah sim.

Acho que o melhor é gerar uma senha aleatória contendo apenas numeros e letras.

Bons estudos!

Quer mergulhar em tecnologia e aprendizagem?

Receba a newsletter que o nosso CEO escreve pessoalmente, com insights do mercado de trabalho, ciência e desenvolvimento de software