Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
以下行失败,但有异常:
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 解决方案。
您应该将 Servlet API 的实现添加到您的测试/运行时类路径中。我建议使用这个依赖:
<dependency> <groupId>org.glassfish</groupId> <artifactId>javax.servlet</artifactId> <version>3.0</version> <scope>test</scope> </dependency>