100字范文,内容丰富有趣,生活中的好帮手!
100字范文 > The jar of this class file belongs to container 'JUnit 4' which does not allow ...

The jar of this class file belongs to container 'JUnit 4' which does not allow ...

时间:2022-11-27 16:27:31

相关推荐

The jar of this class file belongs to container 'JUnit 4' which does not allow ...

The jar of this class file belongs to container 'JUnit 4' which does not allow modification to source attachments on its entries.

代码:

@Testvoid function1(){//1,加载配置文件Configuration configuration = new Configuration().configure();//2,创建sessionFactorySessionFactory sessionFactory = configuration.buildSessionFactory();//3,创建sessionSession session = sessionFactory.openSession();//4,开启事务Transaction transaction = session.beginTransaction();//5,执行事务Customer customer = new Customer();customer.setCust_name("Test");session.save(customer);mit();//6,关闭资源session.close();sessionFactory.close();}

以上是我在用JUnit4 进行Hibernate环境测试时候报的错误,网上搜了一下,各种五花八门的回答,但是感觉都跟我的不沾边,后边检查了一下,发现原来是我的测试方法没有public..加上public就好了

@Testpublic void function1(){//1,加载配置文件Configuration configuration = new Configuration().configure();//2,创建sessionFactorySessionFactory sessionFactory = configuration.buildSessionFactory();//3,创建sessionSession session = sessionFactory.openSession();//4,开启事务Transaction transaction = session.beginTransaction();//5,执行事务Customer customer = new Customer();customer.setCust_name("Test");session.save(customer);mit();//6,关闭资源session.close();sessionFactory.close();}

想知道为什么要加public?

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。