应用程序无法在Spring Boot中启动

时间:2019-06-18 14:55:51

标签: java spring mongodb

我已将spring-boot-starter-data-mongodb依赖项添加到现有项目中。之后,我添加了相关的REST控制器并创建了从MongoDB获取数据的方法。

最初,它在启动过程中没有任何问题,并且已成功连接到日志中可以看到的数据库。完成代码后,我尝试再次启动它,但是开始出现错误。 staack跟踪如下所示:

2019-06-18 09:46:40,172 INFO [main] o.s.d.r.c.RepositoryConfigurationDelegate [RepositoryConfigurationDelegate.java : 163] Multiple Spring Data modules found, entering strict repository configuration mode!
2019-06-18 09:46:40,240 INFO [main] o.s.d.r.c.RepositoryConfigurationDelegate [RepositoryConfigurationDelegate.java : 163] Multiple Spring Data modules found, entering strict repository configuration mode!
2019-06-18 09:46:40,428 INFO [main] o.s.d.r.c.RepositoryConfigurationDelegate [RepositoryConfigurationDelegate.java : 163] Multiple Spring Data modules found, entering strict repository configuration mode!
2019-06-18 09:46:40,443 INFO [main] o.s.d.r.c.RepositoryConfigurationExtensionSupport [RepositoryConfigurationExtensionSupport.java : 283] Spring Data MongoDB - Could not safely identify store assignment for repository candidate interface com.orgname.csi.datasync.intake.repository.IntakeRepository.
2019-06-18 09:46:40,444 INFO [main] o.s.d.r.c.RepositoryConfigurationExtensionSupport [RepositoryConfigurationExtensionSupport.java : 283] Spring Data MongoDB - Could not safely identify store assignment for repository candidate interface com.orgname.csi.datasync.organization.repository.ContactProtocolRepository.
2019-06-18 09:46:40,444 INFO [main] o.s.d.r.c.RepositoryConfigurationExtensionSupport [RepositoryConfigurationExtensionSupport.java : 283] Spring Data MongoDB - Could not safely identify store assignment for repository candidate interface com.orgname.csi.datasync.organization.repository.ExternalSourceRepository.
2019-06-18 09:46:40,445 INFO [main] o.s.d.r.c.RepositoryConfigurationExtensionSupport [RepositoryConfigurationExtensionSupport.java : 283] Spring Data MongoDB - Could not safely identify store assignment for repository candidate interface com.orgname.csi.datasync.organization.repository.LocAttributeRepository.
2019-06-18 09:46:40,446 INFO [main] o.s.d.r.c.RepositoryConfigurationExtensionSupport [RepositoryConfigurationExtensionSupport.java : 283] Spring Data MongoDB - Could not safely identify store assignment for repository candidate interface com.orgname.csi.datasync.organization.repository.NHCoordCareSettingRepository.
2019-06-18 09:46:40,446 INFO [main] o.s.d.r.c.RepositoryConfigurationExtensionSupport [RepositoryConfigurationExtensionSupport.java : 283] Spring Data MongoDB - Could not safely identify store assignment for repository candidate interface com.orgname.csi.datasync.organization.repository.OrganizationCountRepository.
2019-06-18 09:46:40,447 INFO [main] o.s.d.r.c.RepositoryConfigurationExtensionSupport [RepositoryConfigurationExtensionSupport.java : 283] Spring Data MongoDB - Could not safely identify store assignment for repository candidate interface com.orgname.csi.datasync.organization.repository.OrganizationRepository.
2019-06-18 09:46:40,448 INFO [main] o.s.d.r.c.RepositoryConfigurationExtensionSupport [RepositoryConfigurationExtensionSupport.java : 283] Spring Data MongoDB - Could not safely identify store assignment for repository candidate interface com.orgname.csi.datasync.organization.repository.OrgContactMethodRepository.
2019-06-18 09:46:40,448 INFO [main] o.s.d.r.c.RepositoryConfigurationExtensionSupport [RepositoryConfigurationExtensionSupport.java : 283] Spring Data MongoDB - Could not safely identify store assignment for repository candidate interface com.orgname.csi.datasync.organization.repository.OrgEnvironmentTypeRepository.
2019-06-18 09:46:40,448 INFO [main] o.s.d.r.c.RepositoryConfigurationExtensionSupport [RepositoryConfigurationExtensionSupport.java : 283] Spring Data MongoDB - Could not safely identify store assignment for repository candidate interface com.orgname.csi.datasync.organization.repository.OrgExternalSourceRepository.
2019-06-18 09:46:40,449 INFO [main] o.s.d.r.c.RepositoryConfigurationExtensionSupport [RepositoryConfigurationExtensionSupport.java : 283] Spring Data MongoDB - Could not safely identify store assignment for repository candidate interface com.orgname.csi.datasync.organization.repository.OrgRelationshipRepository.
2019-06-18 09:46:40,449 INFO [main] o.s.d.r.c.RepositoryConfigurationExtensionSupport [RepositoryConfigurationExtensionSupport.java : 283] Spring Data MongoDB - Could not safely identify store assignment for repository candidate interface com.orgname.csi.datasync.organization.repository.OrgRelationshipServiceRepository.
2019-06-18 09:46:40,450 INFO [main] o.s.d.r.c.RepositoryConfigurationExtensionSupport [RepositoryConfigurationExtensionSupport.java : 283] Spring Data MongoDB - Could not safely identify store assignment for repository candidate interface com.orgname.csi.datasync.organization.repository.OrgRelationshipTagRepository.
2019-06-18 09:46:40,450 INFO [main] o.s.d.r.c.RepositoryConfigurationExtensionSupport [RepositoryConfigurationExtensionSupport.java : 283] Spring Data MongoDB - Could not safely identify store assignment for repository candidate interface com.orgname.csi.datasync.organization.repository.OrgServiceAreaRepository.
2019-06-18 09:46:40,450 INFO [main] o.s.d.r.c.RepositoryConfigurationExtensionSupport [RepositoryConfigurationExtensionSupport.java : 283] Spring Data MongoDB - Could not safely identify store assignment for repository candidate interface com.orgname.csi.datasync.organization.repository.OrgServiceRatingRepository.
2019-06-18 09:46:40,450 INFO [main] o.s.d.r.c.RepositoryConfigurationExtensionSupport [RepositoryConfigurationExtensionSupport.java : 283] Spring Data MongoDB - Could not safely identify store assignment for repository candidate interface com.orgname.csi.datasync.organization.repository.OrgServiceRepository.
2019-06-18 09:46:40,451 INFO [main] o.s.d.r.c.RepositoryConfigurationExtensionSupport [RepositoryConfigurationExtensionSupport.java : 283] Spring Data MongoDB - Could not safely identify store assignment for repository candidate interface com.orgname.csi.datasync.organization.repository.RatingSourceRepository.
2019-06-18 09:46:40,451 INFO [main] o.s.d.r.c.RepositoryConfigurationExtensionSupport [RepositoryConfigurationExtensionSupport.java : 283] Spring Data MongoDB - Could not safely identify store assignment for repository candidate interface com.orgname.csi.datasync.organization.repository.RelationshipTagsRepository.
2019-06-18 09:46:40,451 INFO [main] o.s.d.r.c.RepositoryConfigurationExtensionSupport [RepositoryConfigurationExtensionSupport.java : 283] Spring Data MongoDB - Could not safely identify store assignment for repository candidate interface com.orgname.csi.datasync.organization.repository.RelationshipTagTypeRepository.
2019-06-18 09:46:41,035 INFO [main] o.a.c.h.Http11NioProtocol [DirectJDKLog.java : 180] Initializing ProtocolHandler ["http-nio-8090"]
2019-06-18 09:46:41,042 INFO [main] o.a.c.c.StandardService [DirectJDKLog.java : 180] Starting service [Tomcat]
2019-06-18 09:46:41,042 INFO [main] o.a.c.c.StandardEngine [DirectJDKLog.java : 180] Starting Servlet Engine: Apache Tomcat/8.5.28
2019-06-18 09:46:41,045 INFO [localhost-startStop-1] o.a.c.c.AprLifecycleListener [DirectJDKLog.java : 180] The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [C:\Program Files\Java\jdk1.8.0_201\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\OpenVPN\bin;C:\Program Files\Git\cmd;C:\WINDOWS\System32\OpenSSH\;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;.]
2019-06-18 09:46:41,201 INFO [localhost-startStop-1] o.a.c.c.C.[.[.[/] [DirectJDKLog.java : 180] Initializing Spring embedded WebApplicationContext
2019-06-18 09:46:41,494 DEBUG [localhost-startStop-1] c.c.c.d.c.MongoConfiguration [MongoConfiguration.java : 37] host is db-mongodev.orgname.local
2019-06-18 09:46:41,494 DEBUG [localhost-startStop-1] c.c.c.d.c.MongoConfiguration [MongoConfiguration.java : 38] port is 27017
2019-06-18 09:46:41,494 DEBUG [localhost-startStop-1] c.c.c.d.c.MongoConfiguration [MongoConfiguration.java : 39] database is orgdatabase
2019-06-18 09:46:42,403 INFO [localhost-startStop-1] o.m.d.cluster [SLF4JLogger.java : 71] Cluster created with settings {hosts=[db-mongodev.orgname.local:27017], mode=SINGLE, requiredClusterType=UNKNOWN, serverSelectionTimeout='30000 ms', maxWaitQueueSize=500}
2019-06-18 09:46:42,674 INFO [localhost-startStop-1] i.s.c.AbstractJestClient [AbstractJestClient.java : 57] Setting server pool to a list of 1 servers: [https://mavdv-cisels-01.orgname.local]
2019-06-18 09:46:42,676 INFO [localhost-startStop-1] i.s.c.JestClientFactory [JestClientFactory.java : 222] Using multi thread/connection supporting pooling connection manager
2019-06-18 09:46:42,737 INFO [localhost-startStop-1] i.s.c.JestClientFactory [JestClientFactory.java : 70] Using custom GSON instance
2019-06-18 09:46:42,737 INFO [localhost-startStop-1] i.s.c.JestClientFactory [JestClientFactory.java : 85] Node Discovery disabled...
2019-06-18 09:46:42,737 INFO [localhost-startStop-1] i.s.c.JestClientFactory [JestClientFactory.java : 97] Idle connection reaping disabled...
2019-06-18 09:46:42,738 INFO [localhost-startStop-1] i.s.c.JestClientFactory [JestClientFactory.java : 102] Authentication cache set for preemptive authentication
2019-06-18 09:46:43,104 INFO [cluster-ClusterId{value='5d08f952f7b760161855baf9', description='null'}-db-mongodev.orgname.local:27017] o.m.d.connection [SLF4JLogger.java : 71] Opened connection [connectionId{localValue:1}] to db-mongodev.orgname.local:27017
2019-06-18 09:46:43,193 INFO [cluster-ClusterId{value='5d08f952f7b760161855baf9', description='null'}-db-mongodev.orgname.local:27017] o.m.d.cluster [SLF4JLogger.java : 71] Monitor thread successfully connected to server with description ServerDescription{address=db-mongodev.orgname.local:27017, type=SHARD_ROUTER, state=CONNECTED, ok=true, version=ServerVersion{versionList=[3, 2, 17]}, minWireVersion=0, maxWireVersion=4, maxDocumentSize=16777216, logicalSessionTimeoutMinutes=null, roundTripTimeNanos=87442300}
2019-06-18 09:46:54,402 INFO [main] c.c.c.d.c.GeoCodeApiConfiguration [GeoCodeApiConfiguration.java : 28] Geo api using auth id: 2af30031-f6aa-bf3f-9906-492c7364700b
2019-06-18 09:46:54,560 INFO [main] o.a.c.c.StandardService [DirectJDKLog.java : 180] Stopping service [Tomcat]
2019-06-18 09:46:54,564 WARN [localhost-startStop-2] o.a.c.l.WebappClassLoaderBase [DirectJDKLog.java : 180] The web application [ROOT] appears to have started a thread named [cluster-ClusterId{value='5d08f952f7b760161855baf9', description='null'}-db-mongodev.orgname.local:27017] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
 sun.misc.Unsafe.park(Native Method)
 java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:215)
 java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2078)
 com.mongodb.connection.DefaultServerMonitor$ServerMonitorRunnable.waitForSignalOrTimeout(DefaultServerMonitor.java:226)
 com.mongodb.connection.DefaultServerMonitor$ServerMonitorRunnable.waitForNext(DefaultServerMonitor.java:207)
 com.mongodb.connection.DefaultServerMonitor$ServerMonitorRunnable.run(DefaultServerMonitor.java:154)
 java.lang.Thread.run(Thread.java:748)
2019-06-18 09:46:54,564 WARN [localhost-startStop-2] o.a.c.l.WebappClassLoaderBase [DirectJDKLog.java : 180] The web application [ROOT] appears to have started a thread named [CleanCursors-1-thread-1] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
 sun.misc.Unsafe.park(Native Method)
 java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:215)
 java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2078)
 java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1093)
 java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:809)
 java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1074)
 java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1134)
 java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
 java.lang.Thread.run(Thread.java:748)

如果您看到日志中最后提到的集群ID,则该集群ID与在同一会话中创建的集群ID相同,并且当Tomcat停止时,它无法终止该进程。因此,可能是由于另一种原因Tomcat正在停止而我无法调试。有人可以帮忙吗?

我的MongoSearch类如下:

`包com.orgname.csi.datasync.repository;

 import com.orgname.csi.datasync.configuration.MongoConfiguration;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.mongodb.core.MongoTemplate;
 import org.springframework.data.mongodb.core.query.Criteria;
 import org.springframework.data.mongodb.core.query.Query;

 import java.util.List;
 import java.util.Map;

 public class MongoSearchRepository<T> {

private static final Logger logger = LoggerFactory.getLogger(MongoSearchRepository.class);

@Autowired
MongoConfiguration mongoConfig;
MongoTemplate mongoTemplate = mongoConfig.mongoTemplate();

//To search for a document with a where clause
protected List<T> findIs(Map<String,String> queryParams, Class<T> clazz){
    Query query = new Query();
    for(Map.Entry<String,String> entry : queryParams.entrySet()){
        query.addCriteria(Criteria.where(entry.getKey()).is(entry.getValue()));
    }
    logger.debug("Query created is {}",query);
    logger.debug("The parameters are {}",queryParams);
    return mongoTemplate.find(query,clazz);
}

} `

1 个答案:

答案 0 :(得分:0)

  

您应该使用MongoRepository界面。

MongoRepository