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

[Bug] erro na aplicação ao subir docker

erro ao subir o docker:

app-1    | 2024-07-24T19:51:04.718Z ERROR 1 --- [           main] o.s.b.web.embedded.tomcat.TomcatStarter  : Error starting Tomcat context. Exception: org.springframework.beans.factory.UnsatisfiedDependencyException. Message: Error creating bean with name 'securityFilter' defined in file [/application/BOOT-INF/classes/br/com/alura/codechella/infra/security/SecurityFilter.class]: Unsatisfied dependency expressed through constructor parameter 1: Error cr
eating bean with name 'usuarioRepository' defined in br.com.alura.codechella.domain.autenticacao.repository.UsuarioRepository defined in @EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration: Cannot resolve reference to bean 'jpaSharedEM_entityManagerFactory' while setting bean property 'entityManager'
4 respostas

No securityFilter também:

app-1    | Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'securityFilter' defined in file [/application/BOOT-INF/classes/br/com/alura/codechella/infra/security/SecurityFilter.class]: Unsatisfied dependency expressed through constructor parameter 1: Error creating bean with name 'usuarioRepository' defined in br.com.alura.codechella.domain.autenticacao.repository.UsuarioRepository defined in @EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration: Cannot resolve reference to bean 'jpaSharedEM_entityManagerFactory' while setting bean property 'entityManager'
app-1    | Caused by: org.flywaydb.core.internal.exception.FlywaySqlException: Unable to obtain connection from database: null,  message from server: "Host '172.18.0.3' is not allowed to connect to this MySQL server"  

acredito q não esta conseguindo criar as tabelas também

meu projeto no git https://github.com/gbrazdev/3700-arquitetura-java

solução!

era algum erro de comunicação com o banco, eu não entendi porque mas o que eu fiz foi expor as portas, rodar primeiro o docker compose so p cirar o container mysql depois descomentei a parte do app e deu certo.

services:
  mysql:
    image: mysql:latest
    env_file: ./env/mysql.env
    volumes:
      - ./mysql-data:/var/lib/mysql
    ports:
      - "3306:3306"
    expose:
      - "3306"
    restart: unless-stopped
    healthcheck:
      test: mysqladmin ping -h 127.0.0.1 -u $$MYSQL_USER --password=$$MYSQL_PASSWORD
      interval: 5s
      timeout: 5s
      retries: 10

  app:
    build:
      context: .
    env_file: ./env/app.env
    restart: unless-stopped
    depends_on:
      mysql:
        condition: service_healthy

volumes:
  mysql-data: