十三,springBoot整合junit

1.依赖

<!--        junit-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>compile</scope>
        </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>--> </dependencies>

2.测试类:

package com.example.test;

import com.CleanSpringBootApplication;
import com.example.pojo.User;
import com.example.service.UserService;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import java.util.List;

/**
 * @RunWith就是一个运行器
 * @RunWith(JUnit4.class)就是指用JUnit4来运行
 * @RunWith(SpringJUnit4ClassRunner.class),让测试运行于Spring测试环境,以便在测试开始的时候自动创建Spring的应用上下文
 * @RunWith(Suite.class)的话就是一套测试集合,
 * @ContextConfiguration Spring整合JUnit4测试时,使用注解引入多个配置文件
 * 单个文件 
 * @ContextConfiguration(Locations="classpath:applicationContext.xml")  
 * @ContextConfiguration(classes = SimpleConfiguration.class)
 * 多个文件时,可用{}
 * @ContextConfiguration(locations = { "classpath:spring1.xml", "classpath:spring2.xml" }) 
 */
@RunWith(SpringJUnit4ClassRunner.class)//替换运行器
@SpringBootTest(classes = CleanSpringBootApplication.class)//属性用于指定引导类,目的是加载ApplicationContext,启动spring容器。
public class Test {

    @Autowired
    private UserService userService;

    @org.junit.Test
    public void test() {
        List<User> users = userService.findAll();
        System.out.println(users);
    }
}

控制台

"C:\Program Files\Java\jdk-11.0.7\bin\java.exe" -ea -Didea.test.cyclic.buffer.size=1048576 "-javaagent:E:\IntelliJ IDEA 2019.1\lib\idea_rt.jar=3427:E:\IntelliJ IDEA 2019.1\bin" -Dfile.encoding=UTF-8 -classpath "E:\IntelliJ IDEA 2019.1\lib\idea_rt.jar;E:\IntelliJ IDEA 2019.1\plugins\junit\lib\junit-rt.jar;E:\IntelliJ IDEA 2019.1\plugins\junit\lib\junit5-rt.jar;D:\学习代码\java\cleanSpringBoot\target\test-classes;D:\学习代码\java\cleanSpringBoot\target\classes;F:\apache-maven-3.6.0\repository\org\springframework\boot\spring-boot-starter-web\2.3.1.RELEASE\spring-boot-starter-web-2.3.1.RELEASE.jar;F:\apache-maven-3.6.0\repository\org\springframework\boot\spring-boot-starter\2.3.1.RELEASE\spring-boot-starter-2.3.1.RELEASE.jar;F:\apache-maven-3.6.0\repository\org\springframework\boot\spring-boot-starter-logging\2.3.1.RELEASE\spring-boot-starter-logging-2.3.1.RELEASE.jar;F:\apache-maven-3.6.0\repository\ch\qos\logback\logback-classic\1.2.3\logback-classic-1.2.3.jar;F:\apache-maven-3.6.0\repository\ch\qos\logback\logback-core\1.2.3\logback-core-1.2.3.jar;F:\apache-maven-3.6.0\repository\org\apache\logging\log4j\log4j-to-slf4j\2.13.3\log4j-to-slf4j-2.13.3.jar;F:\apache-maven-3.6.0\repository\org\apache\logging\log4j\log4j-api\2.13.3\log4j-api-2.13.3.jar;F:\apache-maven-3.6.0\repository\org\slf4j\jul-to-slf4j\1.7.30\jul-to-slf4j-1.7.30.jar;F:\apache-maven-3.6.0\repository\jakarta\annotation\jakarta.annotation-api\1.3.5\jakarta.annotation-api-1.3.5.jar;F:\apache-maven-3.6.0\repository\org\yaml\snakeyaml\1.26\snakeyaml-1.26.jar;F:\apache-maven-3.6.0\repository\org\springframework\boot\spring-boot-starter-json\2.3.1.RELEASE\spring-boot-starter-json-2.3.1.RELEASE.jar;F:\apache-maven-3.6.0\repository\com\fasterxml\jackson\core\jackson-databind\2.11.0\jackson-databind-2.11.0.jar;F:\apache-maven-3.6.0\repository\com\fasterxml\jackson\core\jackson-annotations\2.11.0\jackson-annotations-2.11.0.jar;F:\apache-maven-3.6.0\repository\com\fasterxml\jackson\core\jackson-core\2.11.0\jackson-core-2.11.0.jar;F:\apache-maven-3.6.0\repository\com\fasterxml\jackson\datatype\jackson-datatype-jdk8\2.11.0\jackson-datatype-jdk8-2.11.0.jar;F:\apache-maven-3.6.0\repository\com\fasterxml\jackson\datatype\jackson-datatype-jsr310\2.11.0\jackson-datatype-jsr310-2.11.0.jar;F:\apache-maven-3.6.0\repository\com\fasterxml\jackson\module\jackson-module-parameter-names\2.11.0\jackson-module-parameter-names-2.11.0.jar;F:\apache-maven-3.6.0\repository\org\springframework\boot\spring-boot-starter-tomcat\2.3.1.RELEASE\spring-boot-starter-tomcat-2.3.1.RELEASE.jar;F:\apache-maven-3.6.0\repository\org\apache\tomcat\embed\tomcat-embed-core\9.0.36\tomcat-embed-core-9.0.36.jar;F:\apache-maven-3.6.0\repository\org\glassfish\jakarta.el\3.0.3\jakarta.el-3.0.3.jar;F:\apache-maven-3.6.0\repository\org\apache\tomcat\embed\tomcat-embed-websocket\9.0.36\tomcat-embed-websocket-9.0.36.jar;F:\apache-maven-3.6.0\repository\org\springframework\spring-web\5.2.7.RELEASE\spring-web-5.2.7.RELEASE.jar;F:\apache-maven-3.6.0\repository\org\springframework\spring-beans\5.2.7.RELEASE\spring-beans-5.2.7.RELEASE.jar;F:\apache-maven-3.6.0\repository\org\springframework\spring-webmvc\5.2.7.RELEASE\spring-webmvc-5.2.7.RELEASE.jar;F:\apache-maven-3.6.0\repository\org\springframework\spring-aop\5.2.7.RELEASE\spring-aop-5.2.7.RELEASE.jar;F:\apache-maven-3.6.0\repository\org\springframework\spring-context\5.2.7.RELEASE\spring-context-5.2.7.RELEASE.jar;F:\apache-maven-3.6.0\repository\org\springframework\spring-expression\5.2.7.RELEASE\spring-expression-5.2.7.RELEASE.jar;F:\apache-maven-3.6.0\repository\org\springframework\boot\spring-boot-devtools\2.3.1.RELEASE\spring-boot-devtools-2.3.1.RELEASE.jar;F:\apache-maven-3.6.0\repository\org\springframework\boot\spring-boot\2.3.1.RELEASE\spring-boot-2.3.1.RELEASE.jar;F:\apache-maven-3.6.0\repository\org\springframework\boot\spring-boot-autoconfigure\2.3.1.RELEASE\spring-boot-autoconfigure-2.3.1.RELEASE.jar;F:\apache-maven-3.6.0\repository\org\springframework\boot\spring-boot-starter-data-jpa\2.3.1.RELEASE\spring-boot-starter-data-jpa-2.3.1.RELEASE.jar;F:\apache-maven-3.6.0\repository\org\springframework\boot\spring-boot-starter-aop\2.3.1.RELEASE\spring-boot-starter-aop-2.3.1.RELEASE.jar;F:\apache-maven-3.6.0\repository\org\aspectj\aspectjweaver\1.9.5\aspectjweaver-1.9.5.jar;F:\apache-maven-3.6.0\repository\org\springframework\boot\spring-boot-starter-jdbc\2.3.1.RELEASE\spring-boot-starter-jdbc-2.3.1.RELEASE.jar;F:\apache-maven-3.6.0\repository\com\zaxxer\HikariCP\3.4.5\HikariCP-3.4.5.jar;F:\apache-maven-3.6.0\repository\org\springframework\spring-jdbc\5.2.7.RELEASE\spring-jdbc-5.2.7.RELEASE.jar;F:\apache-maven-3.6.0\repository\jakarta\transaction\jakarta.transaction-api\1.3.3\jakarta.transaction-api-1.3.3.jar;F:\apache-maven-3.6.0\repository\jakarta\persistence\jakarta.persistence-api\2.2.3\jakarta.persistence-api-2.2.3.jar;F:\apache-maven-3.6.0\repository\org\hibernate\hibernate-core\5.4.17.Final\hibernate-core-5.4.17.Final.jar;F:\apache-maven-3.6.0\repository\org\jboss\logging\jboss-logging\3.4.1.Final\jboss-logging-3.4.1.Final.jar;F:\apache-maven-3.6.0\repository\org\javassist\javassist\3.24.0-GA\javassist-3.24.0-GA.jar;F:\apache-maven-3.6.0\repository\net\bytebuddy\byte-buddy\1.10.11\byte-buddy-1.10.11.jar;F:\apache-maven-3.6.0\repository\antlr\antlr\2.7.7\antlr-2.7.7.jar;F:\apache-maven-3.6.0\repository\org\jboss\jandex\2.1.3.Final\jandex-2.1.3.Final.jar;F:\apache-maven-3.6.0\repository\com\fasterxml\classmate\1.5.1\classmate-1.5.1.jar;F:\apache-maven-3.6.0\repository\org\dom4j\dom4j\2.1.3\dom4j-2.1.3.jar;F:\apache-maven-3.6.0\repository\org\hibernate\common\hibernate-commons-annotations\5.1.0.Final\hibernate-commons-annotations-5.1.0.Final.jar;F:\apache-maven-3.6.0\repository\org\glassfish\jaxb\jaxb-runtime\2.3.3\jaxb-runtime-2.3.3.jar;F:\apache-maven-3.6.0\repository\org\glassfish\jaxb\txw2\2.3.3\txw2-2.3.3.jar;F:\apache-maven-3.6.0\repository\com\sun\istack\istack-commons-runtime\3.0.11\istack-commons-runtime-3.0.11.jar;F:\apache-maven-3.6.0\repository\com\sun\activation\jakarta.activation\1.2.2\jakarta.activation-1.2.2.jar;F:\apache-maven-3.6.0\repository\org\springframework\data\spring-data-jpa\2.3.1.RELEASE\spring-data-jpa-2.3.1.RELEASE.jar;F:\apache-maven-3.6.0\repository\org\springframework\data\spring-data-commons\2.3.1.RELEASE\spring-data-commons-2.3.1.RELEASE.jar;F:\apache-maven-3.6.0\repository\org\springframework\spring-orm\5.2.7.RELEASE\spring-orm-5.2.7.RELEASE.jar;F:\apache-maven-3.6.0\repository\org\springframework\spring-tx\5.2.7.RELEASE\spring-tx-5.2.7.RELEASE.jar;F:\apache-maven-3.6.0\repository\org\slf4j\slf4j-api\1.7.30\slf4j-api-1.7.30.jar;F:\apache-maven-3.6.0\repository\org\springframework\spring-aspects\5.2.7.RELEASE\spring-aspects-5.2.7.RELEASE.jar;F:\apache-maven-3.6.0\repository\mysql\mysql-connector-java\8.0.20\mysql-connector-java-8.0.20.jar;F:\apache-maven-3.6.0\repository\org\mybatis\spring\boot\mybatis-spring-boot-starter\1.1.1\mybatis-spring-boot-starter-1.1.1.jar;F:\apache-maven-3.6.0\repository\org\mybatis\spring\boot\mybatis-spring-boot-autoconfigure\1.1.1\mybatis-spring-boot-autoconfigure-1.1.1.jar;F:\apache-maven-3.6.0\repository\org\mybatis\mybatis\3.4.0\mybatis-3.4.0.jar;F:\apache-maven-3.6.0\repository\org\mybatis\mybatis-spring\1.3.0\mybatis-spring-1.3.0.jar;F:\apache-maven-3.6.0\repository\org\springframework\boot\spring-boot-starter-redis\1.3.8.RELEASE\spring-boot-starter-redis-1.3.8.RELEASE.jar;F:\apache-maven-3.6.0\repository\org\springframework\data\spring-data-redis\2.3.1.RELEASE\spring-data-redis-2.3.1.RELEASE.jar;F:\apache-maven-3.6.0\repository\org\springframework\data\spring-data-keyvalue\2.3.1.RELEASE\spring-data-keyvalue-2.3.1.RELEASE.jar;F:\apache-maven-3.6.0\repository\org\springframework\spring-oxm\5.2.7.RELEASE\spring-oxm-5.2.7.RELEASE.jar;F:\apache-maven-3.6.0\repository\org\springframework\spring-context-support\5.2.7.RELEASE\spring-context-support-5.2.7.RELEASE.jar;F:\apache-maven-3.6.0\repository\redis\clients\jedis\3.3.0\jedis-3.3.0.jar;F:\apache-maven-3.6.0\repository\org\apache\commons\commons-pool2\2.8.0\commons-pool2-2.8.0.jar;F:\apache-maven-3.6.0\repository\org\springframework\boot\spring-boot-starter-test\2.3.1.RELEASE\spring-boot-starter-test-2.3.1.RELEASE.jar;F:\apache-maven-3.6.0\repository\org\springframework\boot\spring-boot-test\2.3.1.RELEASE\spring-boot-test-2.3.1.RELEASE.jar;F:\apache-maven-3.6.0\repository\org\springframework\boot\spring-boot-test-autoconfigure\2.3.1.RELEASE\spring-boot-test-autoconfigure-2.3.1.RELEASE.jar;F:\apache-maven-3.6.0\repository\com\jayway\jsonpath\json-path\2.4.0\json-path-2.4.0.jar;F:\apache-maven-3.6.0\repository\net\minidev\json-smart\2.3\json-smart-2.3.jar;F:\apache-maven-3.6.0\repository\net\minidev\accessors-smart\1.2\accessors-smart-1.2.jar;F:\apache-maven-3.6.0\repository\org\ow2\asm\asm\5.0.4\asm-5.0.4.jar;F:\apache-maven-3.6.0\repository\jakarta\xml\bind\jakarta.xml.bind-api\2.3.3\jakarta.xml.bind-api-2.3.3.jar;F:\apache-maven-3.6.0\repository\jakarta\activation\jakarta.activation-api\1.2.2\jakarta.activation-api-1.2.2.jar;F:\apache-maven-3.6.0\repository\org\assertj\assertj-core\3.16.1\assertj-core-3.16.1.jar;F:\apache-maven-3.6.0\repository\org\hamcrest\hamcrest\2.2\hamcrest-2.2.jar;F:\apache-maven-3.6.0\repository\org\junit\jupiter\junit-jupiter\5.6.2\junit-jupiter-5.6.2.jar;F:\apache-maven-3.6.0\repository\org\junit\jupiter\junit-jupiter-api\5.6.2\junit-jupiter-api-5.6.2.jar;F:\apache-maven-3.6.0\repository\org\opentest4j\opentest4j\1.2.0\opentest4j-1.2.0.jar;F:\apache-maven-3.6.0\repository\org\junit\platform\junit-platform-commons\1.6.2\junit-platform-commons-1.6.2.jar;F:\apache-maven-3.6.0\repository\org\junit\jupiter\junit-jupiter-params\5.6.2\junit-jupiter-params-5.6.2.jar;F:\apache-maven-3.6.0\repository\org\junit\jupiter\junit-jupiter-engine\5.6.2\junit-jupiter-engine-5.6.2.jar;F:\apache-maven-3.6.0\repository\org\junit\vintage\junit-vintage-engine\5.6.2\junit-vintage-engine-5.6.2.jar;F:\apache-maven-3.6.0\repository\org\apiguardian\apiguardian-api\1.1.0\apiguardian-api-1.1.0.jar;F:\apache-maven-3.6.0\repository\org\junit\platform\junit-platform-engine\1.6.2\junit-platform-engine-1.6.2.jar;F:\apache-maven-3.6.0\repository\junit\junit\4.13\junit-4.13.jar;F:\apache-maven-3.6.0\repository\org\mockito\mockito-core\3.3.3\mockito-core-3.3.3.jar;F:\apache-maven-3.6.0\repository\net\bytebuddy\byte-buddy-agent\1.10.11\byte-buddy-agent-1.10.11.jar;F:\apache-maven-3.6.0\repository\org\objenesis\objenesis\2.6\objenesis-2.6.jar;F:\apache-maven-3.6.0\repository\org\mockito\mockito-junit-jupiter\3.3.3\mockito-junit-jupiter-3.3.3.jar;F:\apache-maven-3.6.0\repository\org\skyscreamer\jsonassert\1.5.0\jsonassert-1.5.0.jar;F:\apache-maven-3.6.0\repository\com\vaadin\external\google\android-json\0.0.20131108.vaadin1\android-json-0.0.20131108.vaadin1.jar;F:\apache-maven-3.6.0\repository\org\springframework\spring-core\5.2.7.RELEASE\spring-core-5.2.7.RELEASE.jar;F:\apache-maven-3.6.0\repository\org\springframework\spring-jcl\5.2.7.RELEASE\spring-jcl-5.2.7.RELEASE.jar;F:\apache-maven-3.6.0\repository\org\springframework\spring-test\5.2.7.RELEASE\spring-test-5.2.7.RELEASE.jar;F:\apache-maven-3.6.0\repository\org\xmlunit\xmlunit-core\2.7.0\xmlunit-core-2.7.0.jar" com.intellij.rt.execution.junit.JUnitStarter -ideVersion5 -junit4 com.example.test.Test,test
23:40:22.379 [main] DEBUG org.springframework.test.context.junit4.SpringJUnit4ClassRunner - SpringJUnit4ClassRunner constructor called with [class com.example.test.Test]
23:40:22.390 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating CacheAwareContextLoaderDelegate from class [org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate]
23:40:22.413 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating BootstrapContext using constructor [public org.springframework.test.context.support.DefaultBootstrapContext(java.lang.Class,org.springframework.test.context.CacheAwareContextLoaderDelegate)]
23:40:22.538 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating TestContextBootstrapper for test class [com.example.test.Test] from class [org.springframework.boot.test.context.SpringBootTestContextBootstrapper]
23:40:22.590 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Neither @ContextConfiguration nor @ContextHierarchy found for test class [com.example.test.Test], using SpringBootContextLoader
23:40:22.614 [main] DEBUG org.springframework.test.context.support.AbstractContextLoader - Did not detect default resource location for test class [com.example.test.Test]: class path resource [com/example/test/Test-context.xml] does not exist
23:40:22.620 [main] DEBUG org.springframework.test.context.support.AbstractContextLoader - Did not detect default resource location for test class [com.example.test.Test]: class path resource [com/example/test/TestContext.groovy] does not exist
23:40:22.621 [main] INFO org.springframework.test.context.support.AbstractContextLoader - Could not detect default resource locations for test class [com.example.test.Test]: no resource found for suffixes {-context.xml, Context.groovy}.
23:40:22.747 [main] DEBUG org.springframework.test.context.support.ActiveProfilesUtils - Could not find an 'annotation declaring class' for annotation type [org.springframework.test.context.ActiveProfiles] and class [com.example.test.Test]
23:40:23.280 [main] DEBUG org.springframework.boot.test.context.SpringBootTestContextBootstrapper - @TestExecutionListeners is not present for class [com.example.test.Test]: using defaults.
23:40:23.281 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Loaded default TestExecutionListener class names from location [META-INF/spring.factories]: [org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener, org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener, org.springframework.boot.test.autoconfigure.restdocs.RestDocsTestExecutionListener, org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener, org.springframework.boot.test.autoconfigure.webservices.client.MockWebServiceServerTestExecutionListener, org.springframework.test.context.web.ServletTestExecutionListener, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener, org.springframework.test.context.support.DependencyInjectionTestExecutionListener, org.springframework.test.context.support.DirtiesContextTestExecutionListener, org.springframework.test.context.transaction.TransactionalTestExecutionListener, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener, org.springframework.test.context.event.EventPublishingTestExecutionListener]
23:40:23.405 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Using TestExecutionListeners: [org.springframework.test.context.web.ServletTestExecutionListener@6b0d80ed, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener@6f8e8894, org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener@3cfdd820, org.springframework.boot.test.autoconfigure.SpringBootDependencyInjectionTestExecutionListener@928763c, org.springframework.test.context.support.DirtiesContextTestExecutionListener@e25951c, org.springframework.test.context.transaction.TransactionalTestExecutionListener@15f47664, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener@471a9022, org.springframework.test.context.event.EventPublishingTestExecutionListener@dc9876b, org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener@2f666ebb, org.springframework.boot.test.autoconfigure.restdocs.RestDocsTestExecutionListener@19976a65, org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener@a1f72f5, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener@4b2c5e02, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener@57a3e26a, org.springframework.boot.test.autoconfigure.webservices.client.MockWebServiceServerTestExecutionListener@75c56eb9]
23:40:23.410 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved @ProfileValueSourceConfiguration [null] for test class [com.example.test.Test]
23:40:23.424 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved ProfileValueSource type [class org.springframework.test.annotation.SystemProfileValueSource] for class [com.example.test.Test]
23:40:23.455 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved @ProfileValueSourceConfiguration [null] for test class [com.example.test.Test]
23:40:23.459 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved ProfileValueSource type [class org.springframework.test.annotation.SystemProfileValueSource] for class [com.example.test.Test]
23:40:23.460 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved @ProfileValueSourceConfiguration [null] for test class [com.example.test.Test]
23:40:23.460 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved ProfileValueSource type [class org.springframework.test.annotation.SystemProfileValueSource] for class [com.example.test.Test]23:40:23.531 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved @ProfileValueSourceConfiguration [null] for test class [com.example.test.Test]
23:40:23.532 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved ProfileValueSource type [class org.springframework.test.annotation.SystemProfileValueSource] for class [com.example.test.Test]23:40:23.534 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved @ProfileValueSourceConfiguration [null] for test class [com.example.test.Test]
23:40:23.535 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved ProfileValueSource type [class org.springframework.test.annotation.SystemProfileValueSource] for class [com.example.test.Test]
23:40:23.573 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved @ProfileValueSourceConfiguration [null] for test class [com.example.test.Test]
23:40:23.574 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved ProfileValueSource type [class org.springframework.test.annotation.SystemProfileValueSource] for class [com.example.test.Test]
23:40:23.609 [main] DEBUG org.springframework.test.context.support.AbstractDirtiesContextTestExecutionListener - Before test class: context [DefaultTestContext@12299890 testClass = Test, testInstance = [null], testMethod = [null], testException = [null], mergedContextConfiguration = [WebMergedContextConfiguration@2fba3fc4 testClass = Test, locations = '{}', classes = '{class com.CleanSpringBootApplication, class com.CleanSpringBootApplication}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{org.springframework.boot.test.context.SpringBootTestContextBootstrapper=true}', contextCustomizers = set[org.springframework.boot.test.context.filter.ExcludeFilterContextCustomizer@75db5df9, org.springframework.boot.test.json.DuplicateJsonObjectContextCustomizerFactory$DuplicateJsonObjectContextCustomizer@6a2f6f80, org.springframework.boot.test.mock.mockito.MockitoContextCustomizer@0, org.springframework.boot.test.web.client.TestRestTemplateContextCustomizer@6ab778a, org.springframework.boot.test.autoconfigure.properties.PropertyMappingContextCustomizer@0, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverContextCustomizerFactory$Customizer@68567e20, org.springframework.boot.test.context.SpringBootTestArgs@1], resourceBasePath = 'src/main/webapp', contextLoader = 'org.springframework.boot.test.context.SpringBootContextLoader', parent = [null]], attributes = map['org.springframework.test.context.web.ServletTestExecutionListener.activateListener' -> true]], class annotated with @DirtiesContext [false] with mode [null].
23:40:23.616 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved @ProfileValueSourceConfiguration [null] for test class [com.example.test.Test]
23:40:23.617 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved ProfileValueSource type [class org.springframework.test.annotation.SystemProfileValueSource] for class [com.example.test.Test]
23:40:23.808 [main] DEBUG org.springframework.test.context.support.TestPropertySourceUtils - Adding inlined properties to environment: {spring.jmx.enabled=false, org.springframework.boot.test.context.SpringBootTestContextBootstrapper=true}

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.3.1.RELEASE)

2020-07-18 23:40:26.089  INFO 15108 --- [           main] com.example.test.Test                    : Starting Test on DESKTOP-2PVNKVI with PID 15108 (started by Administrator in D:\学习代码\java\cleanSpringBoot)
2020-07-18 23:40:26.092  INFO 15108 --- [           main] com.example.test.Test                    : No active profile set, falling back to default profiles: default
2020-07-18 23:40:35.180  INFO 15108 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configuration mode!
2020-07-18 23:40:35.185  INFO 15108 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFERRED mode.
2020-07-18 23:40:37.352  INFO 15108 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 2141ms. Found 1 JPA repository interfaces.
2020-07-18 23:40:37.398  INFO 15108 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configuration mode!
2020-07-18 23:40:37.402  INFO 15108 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data Redis repositories in DEFAULT mode.
2020-07-18 23:40:38.983  INFO 15108 --- [           main] .RepositoryConfigurationExtensionSupport : Spring Data Redis - Could not safely identify store assignment for repository candidate interface com.example.dao.IUserDao. If you want this repository to be a Redis repository, consider annotating your entities with one of these annotations: org.springframework.data.redis.core.RedisHash (preferred), or consider extending one of the following types with your repository: org.springframework.data.keyvalue.repository.KeyValueRepository.
2020-07-18 23:40:38.983  INFO 15108 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 1558ms. Found 0 Redis repository interfaces.
Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.
2020-07-18 23:40:41.686  INFO 15108 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'
2020-07-18 23:40:42.900  INFO 15108 --- [         task-1] o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [name: default]
2020-07-18 23:40:43.307  INFO 15108 --- [         task-1] org.hibernate.Version                    : HHH000412: Hibernate ORM core version 5.4.17.Final
2020-07-18 23:40:44.358  INFO 15108 --- [         task-1] o.hibernate.annotations.common.Version   : HCANN000001: Hibernate Commons Annotations {5.1.0.Final}
2020-07-18 23:40:44.940  WARN 15108 --- [           main] JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
2020-07-18 23:40:48.749  INFO 15108 --- [         task-1] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
2020-07-18 23:40:48.824  WARN 15108 --- [         task-1] com.zaxxer.hikari.util.DriverDataSource  : Registered driver with driverClassName=com.mysql.jdbc.Driver was not found, trying direct instantiation.
2020-07-18 23:40:50.562  INFO 15108 --- [           main] DeferredRepositoryInitializationListener : Triggering deferred initialization of Spring Data repositories…
2020-07-18 23:40:52.035  INFO 15108 --- [         task-1] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Start completed.
2020-07-18 23:40:52.091  INFO 15108 --- [         task-1] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.MySQL5Dialect
2020-07-18 23:40:54.809  INFO 15108 --- [         task-1] o.h.e.t.j.p.i.JtaPlatformInitiator       : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2020-07-18 23:40:54.827  INFO 15108 --- [         task-1] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2020-07-18 23:40:55.227  INFO 15108 --- [           main] DeferredRepositoryInitializationListener : Spring Data repositories initialized!
2020-07-18 23:40:55.256  INFO 15108 --- [           main] com.example.test.Test                    : Started Test in 31.333 seconds (JVM running for 35.175)
[User{id=1, username='zhangsan', password='123456', name='张三'}, User{id=2, username='lisi', password='123456', name='李四'}, User{id=3, username='wangwu', password='123456', name='王五'}, User{id=4, username='zhangwei', password='123456', name='张伟'}, User{id=5, username='lina', password='123456', name='李娜'}, User{id=6, username='lilei', password='123456', name='李磊'}]
2020-07-18 23:40:55.928  INFO 15108 --- [extShutdownHook] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2020-07-18 23:40:55.934  INFO 15108 --- [extShutdownHook] o.s.s.concurrent.ThreadPoolTaskExecutor  : Shutting down ExecutorService 'applicationTaskExecutor'
2020-07-18 23:40:55.936  INFO 15108 --- [extShutdownHook] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown initiated...
2020-07-18 23:40:55.978  INFO 15108 --- [extShutdownHook] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown completed.

Process finished with exit code 0

 

posted @ 2020-07-18 23:42  指尖下的世界  阅读(647)  评论(0编辑  收藏  举报
/* 看板娘 */ /*炸泡*/
/* 鼠标点击求赞文字特效 */