以下行失败,但有例外:
HttpServletRequest req = mock(HttpServletRequest.class);
例外:
java.lang.ClassFormatError: Absent Code attribute in method
that is not native or abstract in class file
javax/servlet/http/Cookie
有人遇到过这个问题吗?
UPD 找到了解决方案here。
答案 0 :(得分:3)
您应该将Servlet API的实现添加到测试/运行时类路径中。我建议使用这种依赖:
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.servlet</artifactId>
<version>3.0</version>
<scope>test</scope>
</dependency>