2017-09-01 13 views
0

私はmongo依存性を持つスプリングブートプロジェクトを持っています。 mvn clean packageを使用する建物はspring.data.mongodb.host=localhostを使用して動作しますが、spring.data.mongodb.host=<remote-ip-address>を使用すると失敗します。ローカルマシンのIPアドレスにアクセスできないので、春にmongoに接続しようとせずにjarファイルを作成できますか?そこにコンテキストをチェックするテストは、であり、それがオンになっていますデフォルトで春ブートアプリケーションのビルドでmongoをインスタンス化せずにスプリングブートプロジェクトを構築します

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mongoTemplate' defined in class path resource [org/springframework/boot/autoconfigure/data/mongo/MongoDataAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.mongodb.core.MongoTemplate]: Factory method 'mongoTemplate' threw exception; nested exception is org.springframework.dao.DataAccessResourceFailureException: Timed out after 30000 ms while waiting for a server that matches WritableServerSelector. Client view of cluster state is {type=UNKNOWN, servers=[{address=10.37.130.100:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketReadException: Exception receiving message}, caused by {java.net.SocketException: Operation timed out}}]; nested exception is com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting for a server that matches WritableServerSelector. Client view of cluster state is {type=UNKNOWN, servers=[{address=10.37.130.100:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketReadException: Exception receiving message}, caused by {java.net.SocketException: Operation timed out}}]

答えて

0

-

今のところは、エラーの下に与えています。それをオフにするだけです(-DskipTestsプロパティ)。

または、統合テスト用に-Dspring.data.mongodb.host = localhostを使用してビルドします。

関連する問題