我正在尝试使用JHipster implementation作为我Kotlin应用程序的参考来实现Swagger。
但是,当我运行测试时,大多数测试都会出现以下错误(如果删除此错误代码,这些测试将正常工作):
$scope.checkEneteredQuantity = function (qty, bagProduct, index) {
if (qty == 0) {
bagProduct.count = 1;
} else {
var qty = parseInt(qty);
var nwqt = parseInt(qty);
var myflag = 0;
if (qty > 0) {
myflag = 1;
} else if (qty < 0) {
myflag = 2;
}
if (myflag == 1) {
if (bagProduct.return == "simple") {
var cal = parseFloat(bagProduct.count * bagProduct.priceAftertax)
if ((cal % 1) != 0) {
if (cal.toString().split(".")[1].length > 2) {
bagProduct.newpric = parseFloat(cal).toFixed(2);
} else {
bagProduct.newpric = cal;
}
} else {
bagProduct.newpric = cal;
}
//$("#output-text-bulk").click();// this is not working
}
}
}
$("#output-text-bulk").click();
}
我的Caused by:
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'pageableParameterBuilderPlugin' defined in class path resource [com/application/config/apidoc/SwaggerPluginsAutoConfiguration$SpringPagePluginConfiguration.class]: Unsatisfied dependency expressed through method 'pageableParameterBuilderPlugin' parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'springfox.documentation.schema.TypeNameExtractor' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
班:
SwaggerPluginsAutoConfiguration
@Configuration
@ConditionalOnWebApplication
@ConditionalOnBean(Docket::class)
@AutoConfigureAfter(SwaggerAutoConfiguration::class)
class SwaggerPluginsAutoConfiguration {
@Configuration
@ConditionalOnClass(Pageable::class)
class SpringPagePluginConfiguration {
@Bean
@ConditionalOnMissingBean
fun pageableParameterBuilderPlugin(typeNameExtractor: TypeNameExtractor,
typeResolver: TypeResolver): PageableParameterBuilderPlugin {
return PageableParameterBuilderPlugin(typeNameExtractor, typeResolver)
}
}
}
类:
SwaggerAutoConfiguration
如果我在测试应用程序配置文件中包含@Configuration
@ConditionalOnWebApplication
@ConditionalOnClass(ApiInfo::class, BeanValidatorPluginsConfiguration::class, Servlet::class, DispatcherServlet::class)
@Profile(value = [SPRING_PROFILE_SWAGGER])
@EnableSwagger2
@Import(BeanValidatorPluginsConfiguration::class)
class SwaggerAutoConfiguration(applicationProperties: ApplicationProperties) {
...
}
配置文件,则测试通过。但是,如果没有配置文件,则测试将失败,并显示上述错误。我不确定如果未设置配置文件,为什么Spring会尝试配置swagger。
如何进行设置,以便在未指定配置文件的情况下不会尝试加载配置?