问题

springboot项目启动时报异常:-cannot-instantiate-interface-org-springframework-context-applicationlistener-aft
今天使用maven搭建多模块web项目时,遇到了springboot启动失败的异常.

原因

应该是springboot版本不兼容的问题.之前都是使用idea直接新建springboot项目的.
pom文件默认为spring-boot-stater-parent项目的子项目,springboot需要的基础依赖都在这里面.

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.4.3</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

但使用maven直接构建多模块项目时没有办法引入spring-boot-starter-parent项目依赖

解决办法:

在父项目的依赖中引入spring-boot-dependencies

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-dependencies</artifactId>
        <version>2.4.5</version>
        <type>pom</type>
        <scope>import</scope>
    </dependency>
Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐