在学校数据源的时候,还没有开始使用数据源,项目就关闭了。

  为了学习数据源,就只能使用测试类。

  但是,最近需要使用restful进行测试的时候,项目是关闭的,就很糟糕,不好进行测试。

1.日志如下:

 1 D:\jdk1.8.0_144\bin\java -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:47661,suspend=y,server=n -Dfile.encoding=UTF-8 -classpath "D:\jdk1.8.0_144\jre\lib\charsets.jar;D:\jdk1.8.0_144\jre\lib\deploy.jar;D:\jdk1.8.0_144\jre\lib\ext\access-bridge-64.jar;D:\jdk1.8.0_144\jre\lib\ext\cldrdata.jar;D:\jdk1.8.0_144\jre\lib\ext\dnsns.jar;D:\jdk1.8.0_144\jre\lib\ext\jaccess.jar;D:\jdk1.8.0_144\jre\lib\ext\jfxrt.jar;D:\jdk1.8.0_144\jre\lib\ext\localedata.jar;D:\jdk1.8.0_144\jre\lib\ext\nashorn.jar;D:\jdk1.8.0_144\jre\lib\ext\sunec.jar;D:\jdk1.8.0_144\jre\lib\ext\sunjce_provider.jar;D:\jdk1.8.0_144\jre\lib\ext\sunmscapi.jar;D:\jdk1.8.0_144\jre\lib\ext\sunpkcs11.jar;D:\jdk1.8.0_144\jre\lib\ext\zipfs.jar;D:\jdk1.8.0_144\jre\lib\javaws.jar;D:\jdk1.8.0_144\jre\lib\jce.jar;D:\jdk1.8.0_144\jre\lib\jfr.jar;D:\jdk1.8.0_144\jre\lib\jfxswt.jar;D:\jdk1.8.0_144\jre\lib\jsse.jar;D:\jdk1.8.0_144\jre\lib\management-agent.jar;D:\jdk1.8.0_144\jre\lib\plugin.jar;D:\jdk1.8.0_144\jre\lib\resources.jar;D:\jdk1.8.0_144\jre\lib\rt.jar;E:\IDEA_Test\IDEA_springBoot\target\classes;C:\Users\dell\.m2\repository\org\springframework\boot\spring-boot-starter-aop\2.0.6.RELEASE\spring-boot-starter-aop-2.0.6.RELEASE.jar;C:\Users\dell\.m2\repository\org\springframework\boot\spring-boot-starter\2.0.6.RELEASE\spring-boot-starter-2.0.6.RELEASE.jar;C:\Users\dell\.m2\repository\org\springframework\boot\spring-boot-autoconfigure\2.0.6.RELEASE\spring-boot-autoconfigure-2.0.6.RELEASE.jar;C:\Users\dell\.m2\repository\org\springframework\boot\spring-boot-starter-logging\2.0.6.RELEASE\spring-boot-starter-logging-2.0.6.RELEASE.jar;C:\Users\dell\.m2\repository\ch\qos\logback\logback-classic\1.2.3\logback-classic-1.2.3.jar;C:\Users\dell\.m2\repository\ch\qos\logback\logback-core\1.2.3\logback-core-1.2.3.jar;C:\Users\dell\.m2\repository\org\apache\logging\log4j\log4j-to-slf4j\2.10.0\log4j-to-slf4j-2.10.0.jar;C:\Users\dell\.m2\repository\org\apache\logging\log4j\log4j-api\2.10.0\log4j-api-2.10.0.jar;C:\Users\dell\.m2\repository\org\slf4j\jul-to-slf4j\1.7.25\jul-to-slf4j-1.7.25.jar;C:\Users\dell\.m2\repository\org\springframework\spring-aop\5.0.10.RELEASE\spring-aop-5.0.10.RELEASE.jar;C:\Users\dell\.m2\repository\org\springframework\spring-beans\5.0.10.RELEASE\spring-beans-5.0.10.RELEASE.jar;C:\Users\dell\.m2\repository\org\aspectj\aspectjweaver\1.8.13\aspectjweaver-1.8.13.jar;C:\Users\dell\.m2\repository\org\springframework\boot\spring-boot-starter-web\2.0.6.RELEASE\spring-boot-starter-web-2.0.6.RELEASE.jar;C:\Users\dell\.m2\repository\org\springframework\boot\spring-boot-starter-json\2.0.6.RELEASE\spring-boot-starter-json-2.0.6.RELEASE.jar;C:\Users\dell\.m2\repository\com\fasterxml\jackson\core\jackson-databind\2.9.7\jackson-databind-2.9.7.jar;C:\Users\dell\.m2\repository\com\fasterxml\jackson\core\jackson-annotations\2.9.0\jackson-annotations-2.9.0.jar;C:\Users\dell\.m2\repository\com\fasterxml\jackson\core\jackson-core\2.9.7\jackson-core-2.9.7.jar;C:\Users\dell\.m2\repository\com\fasterxml\jackson\datatype\jackson-datatype-jdk8\2.9.7\jackson-datatype-jdk8-2.9.7.jar;C:\Users\dell\.m2\repository\com\fasterxml\jackson\datatype\jackson-datatype-jsr310\2.9.7\jackson-datatype-jsr310-2.9.7.jar;C:\Users\dell\.m2\repository\com\fasterxml\jackson\module\jackson-module-parameter-names\2.9.7\jackson-module-parameter-names-2.9.7.jar;C:\Users\dell\.m2\repository\org\hibernate\validator\hibernate-validator\6.0.13.Final\hibernate-validator-6.0.13.Final.jar;C:\Users\dell\.m2\repository\javax\validation\validation-api\2.0.1.Final\validation-api-2.0.1.Final.jar;C:\Users\dell\.m2\repository\org\jboss\logging\jboss-logging\3.3.2.Final\jboss-logging-3.3.2.Final.jar;C:\Users\dell\.m2\repository\com\fasterxml\classmate\1.3.4\classmate-1.3.4.jar;C:\Users\dell\.m2\repository\org\springframework\spring-web\5.0.10.RELEASE\spring-web-5.0.10.RELEASE.jar;C:\Users\dell\.m2\repository\org\springframework\spring-webmvc\5.0.10.RELEASE\spring-webmvc-5.0.10.RELEASE.jar;C:\Users\dell\.m2\repository\org\springframework\spring-context\5.0.10.RELEASE\spring-context-5.0.10.RELEASE.jar;C:\Users\dell\.m2\repository\org\springframework\spring-expression\5.0.10.RELEASE\spring-expression-5.0.10.RELEASE.jar;C:\Users\dell\.m2\repository\mysql\mysql-connector-java\5.1.47\mysql-connector-java-5.1.47.jar;C:\Users\dell\.m2\repository\org\springframework\boot\spring-boot-starter-jdbc\2.0.6.RELEASE\spring-boot-starter-jdbc-2.0.6.RELEASE.jar;C:\Users\dell\.m2\repository\org\springframework\spring-jdbc\5.0.10.RELEASE\spring-jdbc-5.0.10.RELEASE.jar;C:\Users\dell\.m2\repository\org\springframework\spring-tx\5.0.10.RELEASE\spring-tx-5.0.10.RELEASE.jar;C:\Users\dell\.m2\repository\org\springframework\boot\spring-boot-starter-data-jpa\2.0.6.RELEASE\spring-boot-starter-data-jpa-2.0.6.RELEASE.jar;C:\Users\dell\.m2\repository\javax\transaction\javax.transaction-api\1.2\javax.transaction-api-1.2.jar;C:\Users\dell\.m2\repository\org\hibernate\hibernate-core\5.2.17.Final\hibernate-core-5.2.17.Final.jar;C:\Users\dell\.m2\repository\org\hibernate\javax\persistence\hibernate-jpa-2.1-api\1.0.2.Final\hibernate-jpa-2.1-api-1.0.2.Final.jar;C:\Users\dell\.m2\repository\org\javassist\javassist\3.22.0-GA\javassist-3.22.0-GA.jar;C:\Users\dell\.m2\repository\antlr\antlr\2.7.7\antlr-2.7.7.jar;C:\Users\dell\.m2\repository\org\jboss\jandex\2.0.3.Final\jandex-2.0.3.Final.jar;C:\Users\dell\.m2\repository\dom4j\dom4j\1.6.1\dom4j-1.6.1.jar;C:\Users\dell\.m2\repository\org\hibernate\common\hibernate-commons-annotations\5.0.1.Final\hibernate-commons-annotations-5.0.1.Final.jar;C:\Users\dell\.m2\repository\org\springframework\data\spring-data-jpa\2.0.11.RELEASE\spring-data-jpa-2.0.11.RELEASE.jar;C:\Users\dell\.m2\repository\org\springframework\data\spring-data-commons\2.0.11.RELEASE\spring-data-commons-2.0.11.RELEASE.jar;C:\Users\dell\.m2\repository\org\springframework\spring-orm\5.0.10.RELEASE\spring-orm-5.0.10.RELEASE.jar;C:\Users\dell\.m2\repository\org\springframework\spring-aspects\5.0.10.RELEASE\spring-aspects-5.0.10.RELEASE.jar;C:\Users\dell\.m2\repository\org\apache\tomcat\tomcat-jdbc\8.5.34\tomcat-jdbc-8.5.34.jar;C:\Users\dell\.m2\repository\org\apache\tomcat\tomcat-juli\8.5.34\tomcat-juli-8.5.34.jar;C:\Users\dell\.m2\repository\com\zaxxer\HikariCP\2.7.9\HikariCP-2.7.9.jar;C:\Users\dell\.m2\repository\org\slf4j\slf4j-api\1.7.25\slf4j-api-1.7.25.jar;C:\Users\dell\.m2\repository\org\apache\commons\commons-dbcp2\2.2.0\commons-dbcp2-2.2.0.jar;C:\Users\dell\.m2\repository\org\apache\commons\commons-pool2\2.5.0\commons-pool2-2.5.0.jar;C:\Users\dell\.m2\repository\javax\annotation\javax.annotation-api\1.3.2\javax.annotation-api-1.3.2.jar;C:\Users\dell\.m2\repository\org\springframework\boot\spring-boot-starter-test\2.0.6.RELEASE\spring-boot-starter-test-2.0.6.RELEASE.jar;C:\Users\dell\.m2\repository\org\springframework\boot\spring-boot-test-autoconfigure\2.0.6.RELEASE\spring-boot-test-autoconfigure-2.0.6.RELEASE.jar;C:\Users\dell\.m2\repository\com\jayway\jsonpath\json-path\2.4.0\json-path-2.4.0.jar;C:\Users\dell\.m2\repository\net\minidev\json-smart\2.3\json-smart-2.3.jar;C:\Users\dell\.m2\repository\net\minidev\accessors-smart\1.2\accessors-smart-1.2.jar;C:\Users\dell\.m2\repository\org\ow2\asm\asm\5.0.4\asm-5.0.4.jar;C:\Users\dell\.m2\repository\junit\junit\4.12\junit-4.12.jar;C:\Users\dell\.m2\repository\org\assertj\assertj-core\3.9.1\assertj-core-3.9.1.jar;C:\Users\dell\.m2\repository\org\mockito\mockito-core\2.15.0\mockito-core-2.15.0.jar;C:\Users\dell\.m2\repository\net\bytebuddy\byte-buddy\1.7.11\byte-buddy-1.7.11.jar;C:\Users\dell\.m2\repository\net\bytebuddy\byte-buddy-agent\1.7.11\byte-buddy-agent-1.7.11.jar;C:\Users\dell\.m2\repository\org\objenesis\objenesis\2.6\objenesis-2.6.jar;C:\Users\dell\.m2\repository\org\hamcrest\hamcrest-core\1.3\hamcrest-core-1.3.jar;C:\Users\dell\.m2\repository\org\hamcrest\hamcrest-library\1.3\hamcrest-library-1.3.jar;C:\Users\dell\.m2\repository\org\skyscreamer\jsonassert\1.5.0\jsonassert-1.5.0.jar;C:\Users\dell\.m2\repository\com\vaadin\external\google\android-json\0.0.20131108.vaadin1\android-json-0.0.20131108.vaadin1.jar;C:\Users\dell\.m2\repository\org\springframework\spring-core\5.0.10.RELEASE\spring-core-5.0.10.RELEASE.jar;C:\Users\dell\.m2\repository\org\springframework\spring-jcl\5.0.10.RELEASE\spring-jcl-5.0.10.RELEASE.jar;C:\Users\dell\.m2\repository\org\springframework\spring-test\5.0.10.RELEASE\spring-test-5.0.10.RELEASE.jar;C:\Users\dell\.m2\repository\org\xmlunit\xmlunit-core\2.5.1\xmlunit-core-2.5.1.jar;C:\Users\dell\.m2\repository\org\springframework\boot\spring-boot-configuration-processor\2.0.6.RELEASE\spring-boot-configuration-processor-2.0.6.RELEASE.jar;C:\Users\dell\.m2\repository\org\yaml\snakeyaml\1.23\snakeyaml-1.23.jar;C:\Users\dell\.m2\repository\org\springframework\boot\spring-boot-test\2.0.6.RELEASE\spring-boot-test-2.0.6.RELEASE.jar;C:\Users\dell\.m2\repository\org\springframework\boot\spring-boot\2.0.6.RELEASE\spring-boot-2.0.6.RELEASE.jar;C:\Users\dell\.m2\repository\org\mybatis\spring\boot\mybatis-spring-boot-starter\1.3.1\mybatis-spring-boot-starter-1.3.1.jar;C:\Users\dell\.m2\repository\org\mybatis\spring\boot\mybatis-spring-boot-autoconfigure\1.3.1\mybatis-spring-boot-autoconfigure-1.3.1.jar;C:\Users\dell\.m2\repository\org\mybatis\mybatis\3.4.5\mybatis-3.4.5.jar;C:\Users\dell\.m2\repository\org\mybatis\mybatis-spring\1.3.1\mybatis-spring-1.3.1.jar;D:\IntelliJ IDEA 2017.2\lib\idea_rt.jar" com.springBoot.springbootAndMybatis.ApplicationTest.Application
 2 Connected to the target VM, address: \'127.0.0.1:47661\', transport: \'socket\'
 3 
 4   .   ____          _            __ _ _
 5  /\\ / ___\'_ __ _ _(_)_ __  __ _ \ \ \ \
 6 ( ( )\___ | \'_ | \'_| | \'_ \/ _` | \ \ \ \
 7  \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
 8   \'  |____| .__|_| |_|_| |_\__, | / / / /
 9  =========|_|==============|___/=/_/_/_/
10  :: Spring Boot ::        (v2.0.6.RELEASE)
11 
12 2018-12-05 22:04:03.377  INFO 2360 --- [           main] c.s.s.ApplicationTest.Application        : Starting Application on DESKTOP-TQ4OD79 with PID 2360 (E:\IDEA_Test\IDEA_springBoot\target\classes started by dell in E:\IDEA_Test\IDEA_springBoot)
13 2018-12-05 22:04:03.383  INFO 2360 --- [           main] c.s.s.ApplicationTest.Application        : The following profiles are active: dev
14 2018-12-05 22:04:03.452  INFO 2360 --- [           main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@353352b6: startup date [Wed Dec 05 22:04:03 CST 2018]; root of context hierarchy
15 2018-12-05 22:04:04.170  WARN 2360 --- [           main] o.m.s.mapper.ClassPathMapperScanner      : No MyBatis mapper was found in \'[com.springBoot.springbootAndMybatis.ApplicationTest]\' package. Please check your configuration.
16 2018-12-05 22:04:04.930  INFO 2360 --- [           main] com.zaxxer.hikari.HikariDataSource       : DatebookHikariCP - Starting...
17 2018-12-05 22:04:05.186  INFO 2360 --- [           main] com.zaxxer.hikari.HikariDataSource       : DatebookHikariCP - Start completed.
18 2018-12-05 22:04:05.244  INFO 2360 --- [           main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit \'default\'
19 2018-12-05 22:04:05.271  INFO 2360 --- [           main] o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [
20     name: default
21     ...]
22 2018-12-05 22:04:05.373  INFO 2360 --- [           main] org.hibernate.Version                    : HHH000412: Hibernate Core {5.2.17.Final}
23 2018-12-05 22:04:05.375  INFO 2360 --- [           main] org.hibernate.cfg.Environment            : HHH000206: hibernate.properties not found
24 2018-12-05 22:04:05.431  INFO 2360 --- [           main] o.hibernate.annotations.common.Version   : HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
25 2018-12-05 22:04:05.606  INFO 2360 --- [           main] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.MySQL5Dialect
26 2018-12-05 22:04:06.285  INFO 2360 --- [           main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit \'default\'
27 2018-12-05 22:04:06.971  INFO 2360 --- [           main] c.s.s.ApplicationTest.Application        : Started Application in 4.077 seconds (JVM running for 4.994)
28 2018-12-05 22:04:06.974  INFO 2360 --- [       Thread-2] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@353352b6: startup date [Wed Dec 05 22:04:03 CST 2018]; root of context hierarchy
29 2018-12-05 22:04:06.976  INFO 2360 --- [       Thread-2] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit \'default\'
30 2018-12-05 22:04:06.977  INFO 2360 --- [       Thread-2] com.zaxxer.hikari.HikariDataSource       : DatebookHikariCP - Shutdown initiated...
31 Disconnected from the target VM, address: \'127.0.0.1:47661\', transport: \'socket\'
32 2018-12-05 22:04:06.995  INFO 2360 --- [       Thread-2] com.zaxxer.hikari.HikariDataSource       : DatebookHikariCP - Shutdown completed.
33 
34 Process finished with exit code 0

 

2.解决 方式

  后来百度了,不外乎是两种方式。

  一种加入spring-boot-starter-web依赖,但是这个我在创建springboot项目的时候就存在了。

  然后,还有一种说法,我实验了一下是可以的。

  将provided去掉:

   

 

版权声明:本文为juncaoit原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/juncaoit/p/10073787.html