赞
踩
Cannot instantiate interface org.springframework.context.ApplicationContextInitializer : org.springframework.boot.context.ConfigurationWarningsApplicationContextInitializer
原因
配置pom.xml 把其他的删干净 如 spring
项目中有两个boot的版本,一个高版本一个低版本,导致冲突.
解决方法
查看自己项目中导入的依赖里,是否包含其他版本的boot与自己pom.xml里的boot的版本冲突
最终应该如这般
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>org.example</groupId> <artifactId>spingboot_demo</artifactId> <version>1.0-SNAPSHOT</version> <properties> <!-- 配置的 版本要在这里看清楚--> <!-- druid连接池版本 --> <druid.version>1.1.17</druid.version> <!-- alibaba开发的druid连接池 --> </properties> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <!--版本无所谓的,想用别的也行 爆红 版本较高,阿里云仓库没有--> <version>2.2.2.RELEASE</version> <relativePath/> <!-- lookup parent from repository --> </parent> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> <exclusions> <exclusion> <groupId>org.junit.vintage</groupId> <artifactId>junit-vintage-engine</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>${junit.version}</version> <scope>test</scope> </dependency> <dependency> <groupId>com.alibaba</groupId> <artifactId>druid-spring-boot-starter</artifactId> <!-- 对应properties中的<druid.version> --> <version>${druid.version}</version> </dependency> <!-- <dependency>--> <!-- <groupId>org.springframework</groupId>--> <!-- <artifactId>spring-beans</artifactId>--> <!-- <version>5.3.2</version>--> <!-- <scope>test</scope>--> <!-- </dependency>--> </dependencies> <repositories> <repository> <id>spring-snapshots</id> <url>http://repo.spring.io/libs-snapshot</url> </repository> </repositories> <!--解决版本爆红问题 因为RELEASE版本是不稳定的,于是需要指定spring的仓库 ,在pom.xml后面添加如下代码,然后保存pom.xml文件,就会重新从repo.spring.io中引入jar包--> <pluginRepositories> <pluginRepository> <id>spring-snapshots</id> <url>http://repo.spring.io/libs-snapshot</url> </pluginRepository> </pluginRepositories> <!-- 构建搭建插件 --> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build> </project>
数据库和mybatis版本的依赖
Could not find artifact org.mybatis.spring.boot:mybatis-spring-boot-starter:pom:3.5.6 in aliyun
原来还要在测试类里制定启动类。。。解决办法很简单,把@SpringBootTest()注解改成@SpringBootTest(classes = App.class)就可以了。就像这样:
注:我这里的启动类名为App,更改的时候根据自己启动类名来改
Failed to retrieve application JMX service URL
在 edit configurations 取消勾选 Enable JMX Agent
原因 没写 @RunWith(SpringRunner.class)
报错原因有两个:,没有在方法上指定@Test和@Test的包导错了,spring-test需要的Junit是org.junit.Test,但是在@Test有两个包,另一个是org.junit.jupiter.api.Test,如果将org.junit.Test导错成了org.junit.jupiter.api.Test就会报这个错误,改正包之后问题解决
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。