如果我收到“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
正文到此结束
- 本文标签: 家庭宠物
- 本文链接: https://www.coder6.net/article/2143
- 版权声明: 本文由蚂蚁原创发布,转载请遵循《署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0)》许可协议授权