Exception in thread "main" java.lang.AbstractMethodError: org.springframework.boot.context.confi

现象

Exception in thread "main" java.lang.AbstractMethodError: org.springframework.boot.context.config.ConfigFileApplicationListener.supportsSourceType(Ljava/lang/Class;)Z
	at org.springframework.context.event.GenericApplicationListenerAdapter.supportsSourceType(GenericApplicationListenerAdapter.java:79)
	at org.springframework.context.event.AbstractApplicationEventMulticaster.supportsEvent(AbstractApplicationEventMulticaster.java:289)
	at org.springframework.context.event.AbstractApplicationEventMulticaster.retrieveApplicationListeners(AbstractApplicationEventMulticaster.java:221)
	at org.springframework.context.event.AbstractApplicationEventMulticaster.getApplicationListeners(AbstractApplicationEventMulticaster.java:192)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:128)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:122)
	at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:75)
	at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:53)
	at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:340)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:304)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1213)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1202)
	at com.huawei.HelloApplication.main(HelloApplication.java:20)

根因:

pom以来引入了

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.1.6.RELEASE</version>
</parent>

有手动引入:

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-context</artifactId>
    <version>4.3.9.RELEASE</version>
</dependency>

两者导致冲突,所以报错,删除手动转载的解决

 

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: 这是一个Java编程时的异常错误,它会在程序运行时出现。具体的错误信息是:在主线程中发生了一个抽象方法错误,即“java.lang.abstractmethoderror”,这个错误是由于使用了“org.springframework.boot.context.config.configfileapplicationlistener.supportssourcetype”函数,函数中需要传入一个“java.lang.class”类型的参数,但是实际上这个函数却返回了一个“z”类型的参数,因此出现了错误。 ### 回答2: 这个错误信息是Java中的一种异常,它指出在执行应用程序时遇到了一个抽象方法,并且该方法没有被实现。在这里,错误信息显示了类“ConfigFileApplicationListener”的一个抽象方法“supportsSourceType”没有实现。这个方法需要一个类类型作为参数并返回一个布尔值。由于这个方法没有被实现,当程序尝试调用它时,就会抛出异常并停止运行。 通常情况下,这个方法是由Spring Framework中的ConfigFileApplicationListener类来实现的,它是一个用于读取和解析配置文件的侦听器。在这个错误中,很可能是配置文件的格式或路径不正确,导致ConfigFileApplicationListener在解析配置文件时遇到了问题,并发生了异常。 解决这个问题的方法是先检查配置文件的格式和路径是否正确,并尝试将其更改为正确的格式和路径。如果这不起作用,那么可能需要检查程序中其他的组件,以找出哪个组件没有实现ConfigFileApplicationListener类中的抽象方法,并将其实现。如果所有组件都已正确实现该方法,则可能需要更新您的Spring Framework版本,以修复任何已知的错误。 总之,Exception in thread "main" java.lang.AbstractMethodError异常是Java中的一个常见错误,通常表示在执行程序时发生了问题,需要检查代码中的所有组件和依赖项,以找出并修复问题。要解决这个特定的错误,需要仔细检查配置文件和程序中使用到的其他组件。 ### 回答3: 这个错误是因为缺少实现 org.springframework.boot.context.config.ConfigFileApplicationListener 中的一个抽象方法 supportSourceType(Class<?> sourceType) 导致的。ConfigFileApplicationListener 是 Spring Boot 中的一个配置文件监听器,它会在启动时读取应用的配置文件,并将配置信息加载到 Spring 环境中,支持多种配置文件格式。在实现 ConfigFileApplicationListener 时,需要实现其两个抽象方法: 1. LocationsResolver#getLocations():用于获取配置文件的位置信息,返回值为一个字符串数组。 2. #supportSourceType(Class<?> sourceType):用于指定 ConfigFileApplicationListener 支持的配置文件格式。如果返回值为 true,则表示支持该格式的配置文件。 这个错误提示指出,在实现 ConfigFileApplicationListener 时,没有正确实现 supportSourceType(Class<?> sourceType) 方法,导致出现了 AbstractMethodError 异常。要解决这个问题,需要检查 ConfigFileApplicationListener 的实现代码,看看是否正确实现了 supportSourceType 方法,并确保返回值正确。如果方法实现正确,但仍然存在问题,可能是因为版本不兼容或存在其他冲突。在这种情况下,可以尝试升级或回退 Spring Boot 版本,或者解决与其他依赖库的冲突。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值