ARQUIVO APPLICATION.PROPERTIES spring.profiles.active=dev
ARQUIVO APPLICATION-DEV-PROPERTIES
spring.jpa.hibernate.ddl-auto=update spring.datasource.url=jdbc:mysql://${MYSQL_HOST:db}:3306/dictionary_api_database spring.datasource.username=spring_boot spring.datasource.password=Leonardodev@ spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver spring.jpa.show-sql = true
jwt.secret = secret
flyway.locations=filesystem:db/migration flyway.url = jdbc:mysql://${MYSQL_HOST:db}:3306 flyway.schemas = dictionary_api_database flyway.user = spring_boot flyway.password = Leonardodev@
ARQUIVO DOCKERFILE FROM gradle:8.0.2-jdk19 AS build COPY --chown=gradle:gradle . /home/gradle/src WORKDIR /home/gradle/src RUN gradle build --no-daemon
FROM openjdk:19 EXPOSE 8080 RUN mkdir /app COPY --from=build /home/gradle/src/build/libs/*.jar /app/dictionaryAPI.jar ENTRYPOINT ["java", "-jar", "/app/dictionaryAPI.jar"]
ARQUIVO DOCKER-COMPOSE version: '3' services: db: image: mysql/mysql-server:8.0.28 environment: MYSQL_DATABASE: 'dictionary_api_database' MYSQL_ROOT_PASSWORD: 'Leonardodev@' MYSQL_USER: 'spring_boot' MYSQL_PASSWORD: 'Leonardodev@' ports: - "33306:33306" restart: always volumes: - ./docker/volume_mysql:/var/lib/mysql networks: - dictionary-network
spring-boot: container_name: dictionary_api_database_image build: context: ./ dockerfile: ./Dockerfile image: dictionary_api_database_image
ports:
- "8080:8080"
links:
- db
restart: always
depends_on:
- db
environment:
SPRING_DATASOURCE_URL: jdbc:mysql://db:3306/database?autoReconnect=true&useSSL=false
networks:
- dictionary-network
volumes: dbdata:
networks: dictionary-network: driver: bridge
ESTOU RECEBENDO O SEGUINTE ERRO: Task :test 93.95 93.95 DicionarioApiApplicationTests > contextLoads() FAILED 93.95 java.lang.IllegalStateException at DefaultCacheAwareContextLoaderDelegate.java:143 93.95 Caused by: org.springframework.beans.factory.BeanCreationException at AbstractAutowireCapableBeanFactory.java:1770 93.95 Caused by: org.flywaydb.core.internal.exception.FlywaySqlException at JdbcUtils.java:60 93.96 Caused by: com.mysql.cj.jdbc.exceptions.CommunicationsException at SQLError.java:174 93.96 Caused by: com.mysql.cj.exceptions.CJCommunicationsException at DirectConstructorHandleAccessor.java:67 93.96 Caused by: java.net.UnknownHostException at Inet4AddressImpl.java:-2
QUANDO RODO A APLICAÇÃO COM O BANCO DE DADOS LOCAL, FUNCIONA NORMALMENTE, MAS QUANDO TENDO SUBIR A APLICAÇÃO PARA O CONTAINER DOCKER E INSERINDO O DATABASE URL COM O BANCO CRIADO PELO DOCKER (ARQUIVO DOCKER COMPOSE) RECEBO ESSE ERRO. ALGUÉM PODERIA ME AJUDAR?