第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

使用Docker橋接網(wǎng)絡(luò)時無法在集成測試中獲取JDBC連接

使用Docker橋接網(wǎng)絡(luò)時無法在集成測試中獲取JDBC連接

守候你守候我 2021-05-01 16:57:25
當(dāng)我在maven test本地運(yùn)行時通過。但是,當(dāng)我在CI服務(wù)器上運(yùn)行該錯誤時,出現(xiàn)此錯誤。Error MessageCould not open JPA EntityManager for transaction; nested exception is org.hibernate.exception.JDBCConnectionException: Unable to acquire JDBC ConnectionStacktraceorg.springframework.transaction.CannotCreateTransactionException: Could not open JPA EntityManager for transaction; nested exception is org.hibernate.exception.JDBCConnectionException: Unable to acquire JDBC ConnectionCaused by: org.hibernate.exception.JDBCConnectionException: Unable to acquire JDBC ConnectionCaused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failureThe last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.Caused by: java.net.UnknownHostException: mysql運(yùn)行本地測試時,它們都通過了測試,并使用IntelliJ IDEA提供的maven測試默認(rèn)設(shè)置。由于該錯誤抱怨數(shù)據(jù)庫連接問題,因此我通過Jenkins Audit檢查了Database Plugin。連接成功!我的連接參數(shù)application.properties也與此對應(yīng)spring.datasource.url=jdbc:mysql://mysql:3306/database?useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghaispring.datasource.username=rootspring.datasource.password=passwordspring.datasource.maxActive=5URL中的MySQL是MySQL docker容器名稱。如果用錯誤消息中的localhost或?qū)S肐P進(jìn)行更改docker container inspect mysql是相同的,而后兩行中的Stacktrace則有所不同。對于本地主機(jī)The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.Caused by: java.net.ConnectException: Connection refused (Connection refused)用于私有IPThe last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server. Caused by: java.net.SocketTimeoutException: connect timed out我認(rèn)為不同的是URL中的主機(jī),localhost用于本地測試。而Jenkins服務(wù)器則使用Docker橋接網(wǎng)絡(luò)??偨Y(jié):1.通過maven的本地測試通過2. Jenkins插件成功連接到MySQL3.從Jenkins運(yùn)行時,集成測試失敗。4.本地測試環(huán)境為WIN10 64bit;Jenkins在Ubuntu 16.04 64位服務(wù)器上的docker容器中運(yùn)行,MySQL 5.7容器連接到同一網(wǎng)橋網(wǎng)絡(luò)。
查看完整描述

3 回答

?
牧羊人nacy

TA貢獻(xiàn)1862條經(jīng)驗(yàn) 獲得超7個贊

您應(yīng)該將Docker容器的mysql端口綁定到VM中的端口。

在下面的線程中對此進(jìn)行了很好的解釋。

值得嘗試...
如何與在Docker中作為容器運(yùn)行的MySQL DB連接?


查看完整回答
反對 回復(fù) 2021-05-12
  • 3 回答
  • 0 關(guān)注
  • 520 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號