请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

测试通过不了

@RunWith(SpringRunner.class)
@SpringBootTest
public class ProductCategoryRepositoryTest {
   @Autowired
   private ProductCategoryRepository repository;
   @Test
   public void findOneTest(){
       ProductCategory productCategory=repository.findOne(1);
       System.out.println(productCategory.toString());
   }i

}

测试通过不了

提示:95  INFO 15352 --- [       Thread-3] o.s.w.c.s.GenericWebApplicationContext   : Closing org.springframework.web.context.support.GenericWebApplicationContext@27f981c6: startup date [Wed Aug 16 22:17:29 CST 2017]; root of context hierarchy
2017-08-16 22:17:37.501  INFO 15352 --- [       Thread-3] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'

Process finished with exit code -1

正在回答 回答被采纳积分+3

3回答

Jason8 2018-03-16 12:30:43

@夜深千丈灯 请问你的问题解决了吗?我现在也遇到同样的问题,一链接数据库并进行增删改查操作 就会报这个错

0 回复 有任何疑惑可以回复我~
提问者 夜深千丈灯 2017-08-17 08:51:27

https://img1.sycdn.imooc.com/szimg//5994e7de0001363213660768.jpg

实体类、toSing(),public interface ProductCategoryRepository extends JpaRepository<ProductCategory,Integer>都写了
而且保证没有错误,不知为什么会出现这个错误

0 回复 有任何疑惑可以回复我~
  • 信息还是太少,直接把全部代码发过来吧
    回复 有任何疑惑可以回复我~ 2017-08-17 10:30:25
  • 提问者 夜深千丈灯 回复 廖师兄 #2
    我绝对是按你的代码一步步打下来的
    测试 findOneTest()方法
    提示:
    java.lang.IllegalStateException: Failed to load ApplicationContext
    回复 有任何疑惑可以回复我~ 2017-08-17 12:44:19
  • 提问者 夜深千丈灯 #3
    你的qq号告诉我,我把全部代码给你发过去
    回复 有任何疑惑可以回复我~ 2017-08-17 12:48:36
廖师兄 2017-08-17 00:47:27

截图看看

0 回复 有任何疑惑可以回复我~
问题已解决,确定采纳
还有疑问,暂不采纳
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号