2020-09-23T15:28:00.3483912Zjava.lang.IllegalStateExcture:未能加载Application ationContext 2020-09-23T15:28:00.3489821Z引起的原因:org.springframework.beans.factory.不满意依赖异常:创建在文件[/home/run/work/comation-service中定义名为salecChannelEventProcator的bean时出错/calculation-service/target/classes/com/demo/calculation/saleschannel/SalecChannelEventProcessor.class]:通过构造函数参数1表示的不满足依赖关系;嵌套异常org.springframework.beans.factory.NoSuchBean定义异常:没有类型'de.demo.json.schema.JsonValidator'可用的限定bean:预计至少有1 bean有资格成为自动接线候选人。依赖注释:
import de.demo.json.schema.JsonValidator;
@Configuration
@ComponentScan( basePackages = {
"com.demo",
"de.demo" },
excludeFilters = {
@ComponentScan.Filter( Configuration.class )
} )
@ImportResource("classpath:/spring-context.xml")
@Import({SwaggerConfig.class, SalesChannelSqsConfig.class})
public class SpringMvcConfig extends WebMvcConfigurationSupport {
@Autowired private ApplicationContext applicationContext;
@Bean( name = "objectMapper" )
public ObjectMapper getObjectMapper( JacksonService jacksonService ) {
return jacksonService.getObjectMapper();
}
@Bean(name = "jsonValidator")
public JsonValidator jsonValidator() {
return new JsonValidator();
}
}
@Component
@Slf4j
@RequiredArgsConstructor
public class SalesChannelUpdateListerner {
@NonNull
private final SalesChannelService salesChannelService;
@NonNull
private final SalecChannelEventProcessor salecChannelEventProcessor;
@SqsListener(value = "${sales.channel.update.queue.name}", deletionPolicy = ON_SUCCESS)
@SneakyThrows
public void receiveSalesChannelUpdateEvent(
@NotificationMessage EnvelopedMessage envelopedMessage) {
log.debug("Received message from sales channel update event queue : {}"
}
@Component
@Slf4j
@RequiredArgsConstructor
public class SalecChannelEventProcessor {
private static final String MESSAGE_TYPE = "sales_channel_update";
@NonNull
private final ObjectMapper objectMapper;
@NonNull
private final JsonValidator jsonValidator;
@SneakyThrows(JsonProcessingException.class)
public boolean isValid(EnvelopedMessage envelopedMessage) {
if (!MESSAGE_TYPE.equals(envelopedMessage.getType())) {
return false;
}
return jsonValidator.validate(envelopedMessage);
}
您需要创建JsonValidator
bean。您需要将您的SaleChannelEventProcessor
更改为:
@Component
@Slf4j
@RequiredArgsConstructor
public class SalecChannelEventProcessor {
private static final String MESSAGE_TYPE = "sales_channel_update";
@NonNull
private final ObjectMapper objectMapper;
@Bean
public JsonValidator jsonValidator(){
return new JsonValidator();
}
@SneakyThrows(JsonProcessingException.class)
public boolean isValid(EnvelopedMessage envelopedMessage) {
if (!MESSAGE_TYPE.equals(envelopedMessage.getType())) {
return false;
}
return jsonValidator().validate(envelopedMessage);
}
}
我有一个Spring启动应用程序。我用@Component注释了项目的一个类。现在在我的主类中,当我试图获取该类的bean时,我得到一个异常,它无法找到该bean。 注释为组件的类如下
我在调用get请求(modes-calcul)时遇到这个错误,我不明白为什么...我的依赖注入是正确的吗? ModeCalculController: 谢谢你的帮助..
我得到以下错误消息,而运行我的项目 组织。springframework。豆。工厂UnsatisfiedPendencyException:创建名为“TipoeStatDoCivilController”的bean时出错:通过字段“TipoeStatDoCivilService”表示的未满足的依赖关系;嵌套的异常是org。springframework。豆。工厂UnsatisfiedPendenc
我正在做项目的Spring启动...但是得到了这个错误,而运行应用程序。这可能是H2数据库错误。但是要解决这个错误localhost应该运行,但程序在部署前终止...所以我不能看到什么是实际问题。 错误:org.springframework.beans.factory.BeanCreationException:创建名称为'project TaskRepository'的bean时出错com.a
我有扩张器。js。我在formcontroller中调用此刀。java文件,但我得到以下错误。 我想我需要将DAO定义为一个bean。如何在SpringWebConfig中执行此操作。java文件? 对不起,我对Spring没有太多的控制权 控制台错误: 严重:为servlet[dispatcher]组织分配异常。springframework。豆。工厂NoSuchBeanDefinitionEx
我的servlet-contents.xml