我用spring初始化工具生成一些工作骨架,
我采用MAVEN PROJECT& amp; JAVA& SPRING BOOT 2.0.0
当我运行mvn clean install(没有在项目中做任何更改)时,我得到了以下错误,任何想法如何克服它?
[INFO] Running com.example.restTest.RestTestApplicationTests
12:12:46.554 [main] DEBUG org.springframework.test.context.junit4.SpringJUnit4ClassRunner - SpringJUnit4ClassRunner constructor called with [class com.example.restTest.RestTestApplicationTests]
12:12:46.561 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating CacheAwareContextLoaderDelegate from class [org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate]
12:12:46.568 [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)]
12:12:46.588 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating TestContextBootstrapper for test class [com.example.restTest.RestTestApplicationTests] from class [org.springframework.boot.test.context.SpringBoottestContextBootstrapper]
[ERROR] Tests run: 1,Failures: 0,Errors: 1,Skipped: 0,Time elapsed: 0.197 s <<< FAILURE! - in com.example.restTest.RestTestApplicationTests
[ERROR] initializationError(com.example.restTest.RestTestApplicationTests) Time elapsed: 0.005 s <<< ERROR!
org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.test.context.SpringBootContextLoader]: Unresolvable class deFinition; nested exception is java.lang.NoClassDefFoundError: org/springframework/boot/context/properties/source/ConfigurationPropertySource
Caused by: java.lang.NoClassDefFoundError: org/springframework/boot/context/properties/source/ConfigurationPropertySource
Caused by: java.lang.classNotFoundException: org.springframework.boot.context.properties.source.ConfigurationPropertySource
更新
这是pom.xml文件,我没有改变任何东西……
spring-boot-starter-parent.sourceEncoding>UTF-8.sourceEncoding>
spring-boot-starter-data-restspring-boot-starter-hateoasspring-boot-starter-jerseyspring-boot-starter-securityspring-boot-starter-webspring-boot-starter-tomcatcope>providedcope>
spring-boot-starter-testcope>testcope>
ecurityecurity-testcope>testcope>
UPDATE2
spring-boot-starter-parent.sourceEncoding>UTF-8.sourceEncoding>
spring-boot-starter-data-restspring-boot-starter-hateoasspring-boot-starter-jerseyspring-boot-starter-securityspring-boot-starter-webspring-boot-starter-tomcatcope>providedcope>
spring-boot-starter-testcope>testcope>
ecurityecurity-testcope>testcope>
最佳答案
可能是您添加的依赖项
spring-boot-starter-data-rest
似乎在初始化时需要数据库连接,可能在application.properties文件上提供数据库连接或删除此依赖关系,直到数据库构造可能对您有所帮助.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。