我正在使用Spring 5网络流量、SpringBoot 2和Reactive MongoDB构建一个POC。在使用maven插件构建项目时,我得到了如下错误MongoDB连接错误:-
2018-06-11 10:16:35.415 INFO 16040 --- [localhost:27017] org.mongodb.driver.cluster : Exception in monitor thread while connecting to server localhost:27017
com.mongodb.MongoSocketOpenException: Exception opening socket
at com.mongodb.connection.netty.NettyStream$2.operationComplete(NettyStream.java:158) ~[mongodb-driver-core-3.6.3.jar:na]
at com.mongodb.connection.netty.NettyStream$2.operationComplete(NettyStream.java:145) ~[mongodb-driver-core-3.6.3.jar:na]
at io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:511) ~[netty-common-4.1.24.Final.jar:4.1.24.Final]
at io.netty.util.concurrent.DefaultPromise.notifyListeners0(DefaultPromise.java:504) ~[netty-common-4.1.24.Final.jar:4.1.24.Final]
at io.netty.util.concurrent.DefaultPromise.notifyListenersNow(DefaultPromise.java:483) ~[netty-common-4.1.24.Final.jar:4.1.24.Final]
at io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:424) ~[netty-common-4.1.24.Final.jar:4.1.24.Final]
at io.netty.util.concurrent.DefaultPromise.tryFailure(DefaultPromise.java:121) ~[netty-common-4.1.24.Final.jar:4.1.24.Final]
at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.fulfillConnectPromise(AbstractNioChannel.java:327) ~[netty-transport-4.1.24.Final.jar:4.1.24.Final]
at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.finishConnect(AbstractNioChannel.java:343) ~[netty-transport-4.1.24.Final.jar:4.1.24.Final]
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:633) ~[netty-transport-4.1.24.Final.jar:4.1.24.Final]
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:580) ~[netty-transport-4.1.24.Final.jar:4.1.24.Final]
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:497) ~[netty-transport-4.1.24.Final.jar:4.1.24.Final]
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:459) ~[netty-transport-4.1.24.Final.jar:4.1.24.Final]
at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:884) ~[netty-common-4.1.24.Final.jar:4.1.24.Final]
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) ~[netty-common-4.1.24.Final.jar:4.1.24.Final]
at java.lang.Thread.run(Thread.java:748) [na:1.8.0_171]
Caused by: io.netty.channel.AbstractChannel$AnnotatedConnectException: Connection refused: no further information: localhost/127.0.0.1:27017
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method) ~[na:1.8.0_171]
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717) ~[na:1.8.0_171]
at io.netty.channel.socket.nio.NioSocketChannel.doFinishConnect(NioSocketChannel.java:325) ~[netty-transport-4.1.24.Final.jar:4.1.24.Final]
at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.finishConnect(AbstractNioChannel.java:340) ~[netty-transport-4.1.24.Final.jar:4.1.24.Final]
... 7 common frames omitted
Caused by: java.net.ConnectException: Connection refused: no further information
... 11 common frames omitted
2018-06-11 10:16:35.824 INFO 16040 --- [localhost:27017] org.mongodb.driver.cluster : Exception in monitor thread while connecting to server localhost:27017
com.mongodb.MongoSocketOpenException: Exception opening socket
at com.mongodb.connection.SocketStream.open(SocketStream.java:62) ~[mongodb-driver-core-3.6.3.jar:na]
at com.mongodb.connection.InternalStreamConnection.open(InternalStreamConnection.java:126) ~[mongodb-driver-core-3.6.3.jar:na]
at com.mongodb.connection.DefaultServerMonitor$ServerMonitorRunnable.run(DefaultServerMonitor.java:114) ~[mongodb-driver-core-3.6.3.jar:na]
at java.lang.Thread.run(Thread.java:748) [na:1.8.0_171]
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method) ~[na:1.8.0_171]
at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:85) ~[na:1.8.0_171]
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) ~[na:1.8.0_171]
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) ~[na:1.8.0_171]
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) ~[na:1.8.0_171]
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172) ~[na:1.8.0_171]
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) ~[na:1.8.0_171]
at java.net.Socket.connect(Socket.java:589) ~[na:1.8.0_171]
at com.mongodb.connection.SocketStreamHelper.initialize(SocketStreamHelper.java:59) ~[mongodb-driver-core-3.6.3.jar:na]
at com.mongodb.connection.SocketStream.open(SocketStream.java:57) ~[mongodb-driver-core-3.6.3.jar:na]
... 3 common frames omitted
2018-06-11 10:16:35.852 INFO 16040 --- [ctor-http-nio-1] r.ipc.netty.tcp.BlockingNettyContext : Started HttpServer on /0:0:0:0:0:0:0:0:60327
2018-06-11 10:16:35.855 INFO 16040 --- [ main] o.s.b.web.embedded.netty.NettyWebServer : Netty started on port(s): 60327
以下是我的申请表。属性文件:-
#spring.data.mongodb.uri=mongodb://localhost:27017/webflux_demo
#mongodb
spring.data.mongodb.host=localhost
spring.data.mongodb.port=27017
spring.data.mongodb.database=webflux_demo
#logging
logging.level.org.springframework.data=debug
logging.level.=error
波姆。xml:-
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.myspringboot.microservice.webflux</groupId>
<artifactId>spring-webflux</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>spring-webflux</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.2.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb-reactive</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
请告知这里可能存在什么问题?我是否需要在我的机器上显式安装MongoDB并在运行此项目之前运行它。我相信MongoDB实例将自行运行,因为SpringBoot将在运行时实例化它。
谢谢你
在我的例子中,我使用的是嵌入式mongo。更改构建之后。格雷德尔,它需要刷新。
解决方案-刷新gradle项目[右键单击eclipse中的项目/类似于其他IDE]并运行应用程序。
它将下载... mongodb-win32-x86_64或类似的并正常启动
您可以通过发出以下命令启动mongos进程:
sudo系统控制启动mongod
如果在启动mongod时收到类似以下错误:
启动mongod.service失败:找不到单元mongod.service。首先运行以下命令:
sudosystemctl守护进程重新加载,然后再次运行上面的start命令。
2验证MongoDB是否已成功启动。sudo systemctl状态mongod
我正在尝试使用java邮件api,并且在servlet中有以下代码用于sen mail。我找不到解决错误的方法。 我的控制台中出现以下错误: 原因:java.net.ConnectException:连接被拒绝:java.net.DualStackPlainSocketImpl.connect0(本机方法)java.net.DualStackPlainSocketImpl.socketConnec
问题内容: 我怎样才能捕捉到异常? 问题答案: 通过捕获 所有 异常,并在属性不等于111的情况下重新引发它。或者,更好的是,使用常量代替:
请帮帮我.我使用mongo DB从一个应用程序很长一段时间。该应用程序处于开发模式。有时我看到这个错误 Error-无法调用该操作,最终得到一个错误:org.springframework.dao.DataAccessResourceFailureException:在等待连接10000 ms后超时。群集状态的客户端视图为{type=unknown,servers=[{address=localh
当我在配置单元中运行以下查询时: 这怎么解决呢? 谢谢
我正在尝试通过我的android应用程序使用smack库连接到openfire服务器。当我连接到服务器时,它给我和错误 以下地址失败:“192.168.0.31:5222”失败,因为java.net.SocketException:套接字失败:EACCES(拒绝权限) 从我的登录活动调用SmackConnection.init(用户,密码);它给出java.net.SocketException权
我修改了此处可用于客户端和服务器My Client的示例代码: 我通过创建多个线程在同一台机器上创建多个客户端。线程的数量由n的值决定。当我运行少量客户端时,我不会遇到任何问题,但当我使用n运行500个(即500个客户端线程)时,一些线程会正确运行,但在一些线程中,我会遇到以下情况: 第143行是:所以当我读到这个方法的留档时,它说它抛出: NoConnectionPendingException