我无法使用Docker Compose将MySQL和Play容器进行链接。请看下面的yml文件:
zookeeper:
image: zookeeper:3.4
ports:
- 2181:2181
kafka:
image: ches/kafka:latest
ports:
- 9092:9092
links:
- zookeeper
myDpm:
image: dpm-image:latest
ports:
- 9000:9000
links:
- kafka
- zookeeper
mySql:
image: mysql:latest
environment:
MYSQL_ROOT_PASSWORD: root
myMc3:
image: mc3-v3:3.0
ports:
- 9001:9000
links:
- mySql:3306
environment:
runMode: dev
myElastic:
image: elasticsearch:2.4.0
ports:
- 9200:9200
我想在我的play scala项目中链接mysql,但是出现了一个错误:
[错误] - [play.core.server.netty.PlayDefaultUpstreamHandler] - 无法调用操作 java.sql.SQLTimeoutException: 在等待连接10001ms后超时。 at com.zaxxer.hikari.pool.BaseHikariPool.getConnection(BaseHikariPool.java:227) ~[com.zaxxer.HikariCP-java6-2.3.7.jar:na] at com.zaxxer.hikari.pool.BaseHikariPool.getConnection(BaseHikariPool.java:182) ~[com.zaxxer.HikariCP-java6-2.3.7.jar:na] at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:93) ~[com.zaxxer.HikariCP-java6-2.3.7.jar:na] at slick.jdbc.hikaricp.HikariCPJdbcDataSource.createConnection(HikariCPJdbcDataSource.scala:12) ~[com.typesafe.slick.slick-hikaricp_2.11-3.1.1.jar:na] at slick.jdbc.JdbcBackend$BaseSession.conn$lzycompute(JdbcBackend.scala:415) ~[com.typesafe.slick.slick_2.11-3.1.1.jar:na] at slick.jdbc.JdbcBackend$BaseSession.conn(JdbcBackend.scala:414) ~[com.typesafe.slick.slick_2.11-3.1.1.jar:na] at slick.jdbc.JdbcBackend$SessionDef$class.prepareStatement(JdbcBackend.scala:297) ~[com.typesafe.slick.slick_2.11-3.1.1.jar:na] at slick.jdbc.JdbcBackend$BaseSession.prepareStatement(JdbcBackend.scala:407) ~[com.typesafe.slick.slick_2.11-3.1.1.jar:na] at slick.jdbc.StatementInvoker.results(StatementInvoker.scala:33) ~[com.typesafe.slick.slick_2.11-3.1.1.jar:na] at slick.jdbc.StatementInvoker.iteratorTo(StatementInvoker.scala:22) ~[com.typesafe.slick.slick_2.11-3.1.1.jar:na] at slick.jdbc.Invoker$class.foreach(Invoker.scala:48) ~[com.typesafe.slick.slick_2.11-3.1.1.jar:na] at slick.jdbc.StatementInvoker.foreach(StatementInvoker.scala:16) ~[com.typesafe.slick.slick_2.11-3.1.1.jar:na] at slick.jdbc.Invoker$class.firstOption(Invoker.scala:24) ~[com.typesafe.slick.slick_2.11-3.1.1.jar:na] at slick.jdbc.StatementInvoker.firstOption(StatementInvoker.scala:16) ~[com.typesafe.slick.slick_2.11-3.1.1.jar:na] at slick.jdbc.StreamingInvokerAction$HeadOptionAction.run(StreamingInvokerAction.scala:57) ~[com.typesafe.slick.slick_2.11-3.1.1.jar:na] at slick.jdbc.StreamingInvokerAction$HeadOptionAction.run(StreamingInvokerAction.scala:56) ~[com.typesafe.slick.slick_2.11-3.1.1.jar:na] at slick.backend.DatabaseComponent$DatabaseDef$$anon$2.liftedTree1$1(DatabaseComponent.scala:237) ~[com.typesafe.slick.slick_2.11-3.1.1.jar:na] at slick.backend.DatabaseComponent$DatabaseDef$$anon$2.run(DatabaseComponent.scala:237) ~[com.typesafe.slick.slick_2.11-3.1.1.jar:na] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) ~[na:1.8.0_111] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) ~[na:1.8.0_111] at java.lang.Thread.run(Thread.java:745) ~[na:1.8.0_111] 原因: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: 通信链接失败