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);transaction.commit();//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);transaction.commit();//6,关闭资源session.close();sessionFactory.close();}

想知道为什么要加public?

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

  1. Android 无法查看外部依赖jar的源码的问题

    在Eclipse中开发android的应用程序时,有时想查看函数的内部实现,但是当在函数上点击ctrl和鼠标左键的时候, 往往出现如下提示: Class File Editor Source not ...

  2. Eclipse Scala环境的配置

    前言 要开发Scala程序, 一般使用的IDE主要有3种: NetBean Eclipse IDEA 由于个人不太习惯IDEA的一些使用功能, 已经只能打开一个项目.(这可太蠢了.) 所以, 继续选择 ...

  3. maven-shade-plugin A required class was missing org/sonatype/aether/version/VersionConstraint

    问题描述 在用jenkins 编译研发代码的时候,报如下错误: [ERROR] Failed to execute goal org.apache.maven.plugins:maven-shade- ...

  4. idea报错Shorten the command line via JAR manifest or via a classpath file and rerun.

    问题描述 启动SpringBoot项目,报错 Error running DeskApplication. Command line is too long. Shorten the command ...

  5. 【Java】解决执行mvn spring-boot:run报错jar时出错; zip file is empty

    问题描述 在执行mvn spring-boot:run的时候,报错 [ERROR] 读取/Users/diandianxiyu_geek/.m2/repository/org/apache/tomca ...

  6. 导入AAR报错 Failed to transform file 'xxx.aar' to match attributes {artifactType=jar}

    Failed to transform file 'xxx.aar' to match attributes {artifactType=jar} Failed to transform file ' ...

  7. Android动态加载jar/dex

    http://www.cnblogs.com/over140/archive/2011/11/23/2259367.html 加载jar boolean bool = new File("/ ...

  8. Maven : 将Jar安装到本地仓库和Jar上传到私服[转]

    原文地址 :https://www.cnblogs.com/shindo/p/6609797.html 1.单个jar上上传 方法一:利用界面  使用Sonatype Nexus搭建Maven私服后添 ...

  9. java 加载jar_java手动加载jar

    @RequestMapping("/testJar")public @ResponseBody String exteriorJar(int ys, int csd,int jg, ...

  10. android studio 将文件打包成jar文件

    1. File ->new Moudle -> android library 这样就创建了一个library工程 打开他的build.gradle 工程 apply plugin: 'c ...

最新文章

  1. linux启动tomcat不停的触发gc,tomcat的rmi触发的full gc的时间过长的优化
  2. Git 学习(二)版本库创建
  3. kettle获取当前日期_kettle中通过 时间戳(timestamp)方式 来实现数据库的增量同步操作(一)...
  4. hdu5386(暴力)
  5. 第三次学JAVA再学不好就吃翔(part65)--正则表达式
  6. Linux常用命令(知道啦就赶紧收藏吧)
  7. 安装composer 提示需要反复重启解决办法
  8. C++常见面试题-30道
  9. DirectX SDK (June 2010)安装遇到Error Code S1023
  10. Web开发技术——JQuery8(添加元素和删除元素)
  11. 怎样测网络服务器延迟,网速测试延迟(网络延迟多少正常)
  12. Latex安装流程(图文)
  13. iOS 安装包瘦身 (上篇)
  14. 如何使用多种方法在 Mac 上截屏?
  15. 得空写的基于web的工作流表单设计器,大家看看怎么样
  16. 一份个人计算机能力研修总结,计算机 个人研修总结
  17. mybatis-plus le ge 记录
  18. 学生信息管理系统(头哥适用版)(c语言)
  19. AI时代,APP运营是否会被淘汰
  20. 第7章:OFDM 信道估计与均衡(1)

热门文章

  1. C# 使用Microsoft.Reporting打印票据
  2. “Python小屋”1300篇历史文章分类速查表
  3. 由一本书看一个行业 -- 网上购书之比较
  4. 数字电视加密技术工作原理(EMM ECM)
  5. linux启动报错23修复
  6. SQLServer 2016安装时的错误:Polybase要求安装Oracle JRE 7更新51或更高版本
  7. 计算机交流会活动流程,新老生交流会活动方案
  8. py文件编译成pyc文件
  9. fckeditor 2.6 php,fckeditor = 2.6.4 任意文件上传漏洞
  10. 怎样备份计算机里的驱动程序,怎么备份电脑的驱动 驱动人生备份驱动方法