原创

如果我收到“Socket failed to connect to host”(套接字无法连接到主机),会出现什么问题?

温馨提示:
本文最后更新于 2024年04月12日,已超过 37 天没有更新。若文章内的图片失效(无法正常加载),请留言反馈或直接联系我

I'm trying to connect to my container with my empty java maven project. But I received an error Socket fail to connect to host:address=(host=studentdb)(port=3306)(type=primary). studentdb

What would be the problem in my docker-compose.yml

version: '3.8'

services:
  mariadb:
    build:
      context: .
    container_name: studentdb
    networks:
      - default
    ports:
      - "3306:3306"
    expose:
      - "3306"
    volumes:
      - ./data:/var/lib/mysql
    environment:
      MYSQL_ROOT_PASSWORD: ${DB_ROOT_PASSWORD}
      MYSQL_DATABASE: ${DB_NAME}
      MYSQL_USER: ${DB_APPLICATION_USER}
      MYSQL_PASSWORD: ${DB_APPLICATION_PASSWORD}

And this is my application.properties:

spring.application.name=student
spring.datasource.url=jdbc:mariadb://studentdb:3306/student
spring.jpa.hibernate.ddl-auto=none
spring.jpa.database-platform=org.hibernate.dialect.MariaDBDialect
spring.datasource.driver-class-name=org.mariadb.jdbc.Driver
spring.jpa.properties.javax.persistence.validation.mode=none
server.error.whitelabel.enabled=false
正文到此结束
热门推荐
本文目录