Spring测试时的报错

55 篇文章 0 订阅

Spring测试报错,反正就是报错,各种报错:

 

我的错误过程:

错误1

警告报错:

log4j:WARN No appenders could be found for logger (org.springframework.context.support.ClassPathXmlApplicationContext).

log4j:WARN Please initialize the log4j system properly.

解决办法是导入这两个包,但是导入之后虽然警告消失,但是测试并不能成功:

错误2

Failed to load ApplicationContext

我的错误原因是没有导入spring的包:

错误3

解决办法:我的是缺少jar包,导入下面的这个包则不会报上面的错错,但是会出现新的错误:

出现新错误:

日了个老母,老子的包竟然多导入了一个,鸡儿

我多导入了一个此包,导致和其他的spring相关包版本冲突,但是spring这个包最高版本并没有其他包那么高,所以我觉得没错,导致我导入了许多其他解决一个报错包,但是又导致另一个报错的,这样循环,导致上面的错误1,错误2,根源在spring这个包版本错误,将此包注释掉

现在想来,我的错误就是第九种错误:

最后附上我的pom.xml:

<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>com.atguigu</groupId>
  <artifactId>ssm-crud</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>war</packaging>
  <!-- 引入项目依赖的包 -->
  <!-- SpringMVC,Spring   到maven的中央仓库maven respository-->  
  <!-- https://mvnrepository.com/artifact/org.springframework/spring-webmvc -->
	<properties>
		<spring.version>4.3.7.RELEASE</spring.version>
	</properties>
  <dependencies>
    <!-- https://mvnrepository.com/artifact/org.springframework/spring-orm -->
	<dependency>
	    <groupId>org.springframework</groupId>
	    <artifactId>spring-orm</artifactId>
		<version>4.3.7.RELEASE</version>
	</dependency>

  	<!-- MBG 逆向工程 -->
  	<!-- https://mvnrepository.com/artifact/org.mybatis.generator/mybatis-generator-core -->
	<dependency>
	    <groupId>org.mybatis.generator</groupId>
	    <artifactId>mybatis-generator-core</artifactId>
	    <version>1.3.2</version>
	</dependency> 
                                                                            
  	<!-- 1.Springmvc -->
  	<dependency>
	  <groupId>org.springframework</groupId>
	  <artifactId>spring-webmvc</artifactId>
	  <version>4.3.7.RELEASE</version>
    </dependency>
    <!-- 2.Spring -Jdbc -->
    <!-- https://mvnrepository.com/artifact/org.springframework/spring-test -->
	<dependency>
		<groupId>org.springframework</groupId>
		<artifactId>spring-jdbc</artifactId>
		<version>4.3.7.RELEASE</version>
	</dependency>
	<!-- 3.Spring-Test -->
	<!-- https://mvnrepository.com/artifact/org.springframework/spring-test -->
	<dependency>
	    <groupId>org.springframework</groupId>
	    <artifactId>spring-test</artifactId>
		<version>4.3.7.RELEASE</version>
	    <!-- <scope>test</scope> -->
	</dependency>
	
	<!-- https://mvnrepository.com/artifact/org.hamcrest/hamcrest-core -->
	<dependency>
	    <groupId>org.hamcrest</groupId>
	    <artifactId>hamcrest-core</artifactId>
	    <version>2.1-rc4</version>
	    <scope>test</scope>
	</dependency>
	<!-- https://mvnrepository.com/artifact/org.hamcrest/hamcrest -->
	<dependency>
	    <groupId>org.hamcrest</groupId>
	    <artifactId>hamcrest</artifactId>
	    <version>2.1-rc4</version>
	</dependency>
		
	<!-- https://mvnrepository.com/artifact/org.hamcrest/hamcrest-junit -->
	<dependency>
	    <groupId>org.hamcrest</groupId>
	    <artifactId>hamcrest-junit</artifactId>
	    <version>2.0.0.0</version>
	    <scope>test</scope>
	</dependency>
	<!-- https://mvnrepository.com/artifact/org.hamcrest/java-hamcrest -->
	<dependency>
	    <groupId>org.hamcrest</groupId>
	    <artifactId>java-hamcrest</artifactId>
	    <version>2.0.0.0</version>
	    <scope>test</scope>
	</dependency>

    <!-- Spring 面向切面编程 -->
    <!-- https://mvnrepository.com/artifact/org.springframework/spring-aspects -->
	<dependency>
	    <groupId>org.springframework</groupId>
	    <artifactId>spring-aspects</artifactId>
		<version>4.3.7.RELEASE</version>
	</dependency>
	<!-- https://mvnrepository.com/artifact/org.springframework/spring-aop -->
	<dependency>
	    <groupId>org.springframework</groupId>
	    <artifactId>spring-aop</artifactId>
		<version>4.3.7.RELEASE</version>
	</dependency>

    <!-- 4.Mybatis -->
    <!-- https://mvnrepository.com/artifact/org.mybatis/mybatis -->
	<dependency>
	    <groupId>org.mybatis</groupId>
	    <artifactId>mybatis</artifactId>
	    <version>3.4.2</version>
	</dependency>
	
	<!-- 5.Mybatis整合Spring的适配包 -->
	<!-- https://mvnrepository.com/artifact/org.mybatis/mybatis-spring -->
	<dependency>
	    <groupId>org.mybatis</groupId>
	    <artifactId>mybatis-spring</artifactId>
	    <version>1.3.2</version>
	</dependency>
	
	<!-- 6.数据库连接池 .驱动-->
	<!-- https://mvnrepository.com/artifact/com.mchange/c3p0 -->
	<dependency>
	    <groupId>com.mchange</groupId>
	    <artifactId>c3p0</artifactId>
	    <version>0.9.2</version>
	</dependency>
	
	<!-- 7.Mysql -->
	<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
	<dependency>
	    <groupId>mysql</groupId>
	    <artifactId>mysql-connector-java</artifactId>
	    <version>5.1.41</version>
	</dependency>
	
	<!-- 8.jstl,servlet-api,junit -->
    <!-- https://mvnrepository.com/artifact/javax.servlet/jstl -->
	<dependency>
	    <groupId>javax.servlet</groupId>
	    <artifactId>jstl</artifactId>
	    <version>1.2</version>
	</dependency>
   
    <!-- https://mvnrepository.com/artifact/javax.servlet/servlet-api -->
	<dependency>
	    <groupId>javax.servlet</groupId>
	    <artifactId>servlet-api</artifactId>
	    <version>2.5</version>
	    <scope>provided</scope>
	</dependency>

    <!-- https://mvnrepository.com/artifact/junit/junit -->
	<dependency>
	    <groupId>junit</groupId>
	    <artifactId>junit</artifactId>
	    <version>4.12</version>
	</dependency>
		
	<!-- spring 的配置文件 -->
	<!-- https://mvnrepository.com/artifact/org.springframework/spring-context -->
	<dependency>
	    <groupId>org.springframework</groupId>
	    <artifactId>spring-context</artifactId>
		<version>4.3.7.RELEASE</version>
	</dependency>

	<!-- https://mvnrepository.com/artifact/org.apache.tomcat/tomcat-juli -->
	<dependency>
	    <groupId>org.apache.tomcat</groupId>
	    <artifactId>tomcat-juli</artifactId>
	    <version>8.5.20</version>
	</dependency>   			
  </dependencies>
</project>

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值