@EnableAutoConfiguration(exclude={MongoAutoConfiguration.class})

springboot 项目启动报错如下,分析是pom.xml中引入了mongdb的依赖,此时你可能不需要连接数据库,那么有两种解决方式:

1.在pom.xml中找到对应的依赖,去除掉

2.可以在启动类上通过禁用指定的自动化配置来避免加载不必要的自动化配置,例如:

@EnableAutoConfiguration(exclude={MongoAutoConfiguration.class})
2021-03-30 16:04:49.152  WARN 7864 --- [           main] io.undertow.websockets.jsr               : UT026010: Buffer pool was not set on WebSocketDeploymentInfo, the default pool will be used
2021-03-30 16:04:49.233  INFO 7864 --- [           main] io.undertow.servlet                      : Initializing Spring embedded WebApplicationContext
2021-03-30 16:04:49.233  INFO 7864 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 4438 ms
2021-03-30 16:04:50.615  INFO 7864 --- [           main] c.a.c.s.SentinelWebAutoConfiguration     : [Sentinel Starter] register SentinelWebInterceptor with urlPatterns: [/**].
2021-03-30 16:04:52.210  INFO 7864 --- [           main] c.a.d.s.b.a.DruidDataSourceAutoConfigure : Init DruidDataSource
2021-03-30 16:04:52.457  INFO 7864 --- [           main] com.alibaba.druid.pool.DruidDataSource   : {dataSource-1} inited
2021-03-30 16:04:52.846  INFO 7864 --- [           main] o.s.b.a.e.web.EndpointLinksResolver      : Exposing 22 endpoint(s) beneath base path '/actuator'
2021-03-30 16:04:53.682  WARN 7864 --- [           main] c.n.c.sources.URLConfigurationSource     : No URLs will be polled as dynamic configuration sources.
2021-03-30 16:04:53.683  INFO 7864 --- [           main] c.n.c.sources.URLConfigurationSource     : To enable URLs as dynamic configuration sources, define System property archaius.configurationSource.additionalUrls or make config.properties available on classpath.
2021-03-30 16:04:53.693  WARN 7864 --- [           main] c.n.c.sources.URLConfigurationSource     : No URLs will be polled as dynamic configuration sources.
2021-03-30 16:04:53.693  INFO 7864 --- [           main] c.n.c.sources.URLConfigurationSource     : To enable URLs as dynamic configuration sources, define System property archaius.configurationSource.additionalUrls or make config.properties available on classpath.
2021-03-30 16:04:53.974  INFO 7864 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'
2021-03-30 16:04:54.246  INFO 7864 --- [           main] o.s.s.c.ThreadPoolTaskScheduler          : Initializing ExecutorService 'Nacos-Watch-Task-Scheduler'
2021-03-30 16:04:56.743  INFO 7864 --- [           main] o.s.s.web.DefaultSecurityFilterChain     : Creating filter chain: any request, [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@b42d1c8, org.springframework.security.web.context.SecurityContextPersistenceFilter@5b9ed77b, org.springframework.security.web.header.HeaderWriterFilter@30eed725, org.springframework.security.web.authentication.logout.LogoutFilter@555454c7, org.springframework.security.oauth2.provider.authentication.OAuth2AuthenticationProcessingFilter@9751c9, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@4b4a3114, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@7955b4d4, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@73983f07, org.springframework.security.web.session.SessionManagementFilter@89017e5, org.springframework.security.web.access.ExceptionTranslationFilter@5fb392e, org.springframework.security.web.access.intercept.FilterSecurityInterceptor@4a5dc126]
2021-03-30 16:04:57.073  INFO 7864 --- [           main] org.mongodb.driver.cluster               : Cluster created with settings {hosts=[localhost:27017], mode=SINGLE, requiredClusterType=UNKNOWN, serverSelectionTimeout='30000 ms', maxWaitQueueSize=500}
2021-03-30 16:04:57.972  WARN 7864 --- [           main] s.o.SpringCloudSecurityAutoConfiguration : All Spring Cloud Security modules and starters are deprecated. They will be moved to individual projects in the next major release.
2021-03-30 16:04:58.277  INFO 7864 --- [           main] io.undertow                              : starting server: Undertow - 2.1.4.Final
2021-03-30 16:04:58.292  INFO 7864 --- [           main] org.xnio                                 : XNIO version 3.8.0.Final
2021-03-30 16:04:58.322  INFO 7864 --- [           main] org.xnio.nio                             : XNIO NIO Implementation Version 3.8.0.Final
2021-03-30 16:04:58.406  INFO 7864 --- [           main] org.jboss.threads                        : JBoss Threads version 3.1.0.Final
2021-03-30 16:04:58.513  INFO 7864 --- [           main] o.s.b.w.e.undertow.UndertowWebServer     : Undertow started on port(s) 6062 (http)
2021-03-30 16:04:58.525  INFO 7864 --- [           main] c.a.c.n.registry.NacosServiceRegistry    : nacos registry, DEFAULT_GROUP qn-report-biz 10.130.14.6:6062 register finished
2021-03-30 16:04:59.155  INFO 7864 --- [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.internal.connection.SocketStream.open(SocketStream.java:70)
	at com.mongodb.internal.connection.InternalStreamConnection.open(InternalStreamConnection.java:128)
	at com.mongodb.internal.connection.DefaultServerMonitor$ServerMonitorRunnable.run(DefaultServerMonitor.java:117)
	at java.lang.Thread.run(Thread.java:748)
Caused by: java.net.ConnectException: Connection refused: connect
	at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method)
	at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:85)
	at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
	at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
	at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
	at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
	at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
	at java.net.Socket.connect(Socket.java:589)
	at com.mongodb.internal.connection.SocketStreamHelper.initialize(SocketStreamHelper.java:64)
	at com.mongodb.internal.connection.SocketStream.initializeSocket(SocketStream.java:79)
	at com.mongodb.internal.connection.SocketStream.open(SocketStream.java:65)
	... 3 common frames omitted

2021-03-30 16:04:59.803  INFO 7864 --- [           main] com.channelsoft.qn.report.App            : Started App in 18.809 seconds (JVM running for 21.935)

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值