我的应用程序正在使用 Spring-Boot 框架。一切正常,直到发生 GC 开销错误。GC 错误已恢复,但 mongodb 连接在此之后不断出现此错误。但与此同时,其他使用同一个 mongodb 服务器的应用程序能够正常连接到它。一旦我重新启动我的 spring-boot 应用程序,这个错误就消失了。
com.mongodb.MongoInternalException: The responseTo (130) in the response does not match the requestId (131) in the request.每个请求都有例外,responseTo 和 requestId 值不同。
我想知道这个问题是不是因为 OutOfMemoryError?如果不是,此错误的其他可能原因是什么?
在我的 Spring Boot 应用程序中,我正在使用 @SpringBootTest 编写集成测试。我正在使用配置类并在其上使用@ComponentScan,但它没有加载组件并且测试失败。
应用程序配置.java
@Configuration
@ComponentScan(basePackages = { "com.example.inventory" })
public class ApplicationConfig {
@Bean
public MapperFactory mapperFactory() {
return new DefaultMapperFactory.Builder().build();
}
}
Run Code Online (Sandbox Code Playgroud)
这里的 DefaultMapperFactory 是 Orika Mapper 的一部分,我用它来将模型转换为 DTO,反之亦然。
ProductSupplierIntegrationTests.java
@SpringBootTest(classes = ApplicationConfig.class)
@RunWith(SpringRunner.class)
@AutoConfigureMockMvc
public class ProductSupplierIntegrationTests {
// tests
}
Run Code Online (Sandbox Code Playgroud)
产品供应商模式
@Entity
public class ProductSupplier {
@Id
@GeneratedValue
private Long id;
private Long supplierId;
@ManyToOne
private Supplier supplier;
private Double buyPrice;
private boolean defaultSupplier;
// getters and setters
}
Run Code Online (Sandbox Code Playgroud)
供应商模式
@Entity
public class …Run Code Online (Sandbox Code Playgroud)