我正在尝试使用Spring xml配置连接MongoDB我收到此错误:
INFO:org.mongodb.driver.cluster - 连接到服务器时监视器线程中的异常192.168.1.7:27071 com.mongodb.MongoSocketOpenException:异常打开套接字
的web.xml
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>appServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/appServlet/servlet-context.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>appServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
servlet的context.xml中
<beans:beans>
<mongo:mongo host="192.168.1.7" port="27071"></mongo:mongo>
<beans:bean id="mongoTemplate" class="org.springframework.data.mongodb.core.MongoTemplate">
<beans:constructor-arg ref="mongo"></beans:constructor-arg>
<beans:constructor-arg value="admin"></beans:constructor-arg>
</beans:bean>
<mongo:repositories base-package="com.excelit.login"></mongo:repositories>
</beans:bean>