为了账号安全,请及时绑定邮箱和手机立即绑定

log4j2 在servlet3.1下报错NoClassDefFoundError

log4j2 在servlet3.1下报错NoClassDefFoundError

哈士奇WWW 2019-02-20 21:00:06
我的maven配置 <dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-web</artifactId> <version>2.8.1</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-api</artifactId> <version>2.8.1</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-core</artifactId> <version>2.8.1</version> <scope>compile</scope> </dependency> 然后我在main函数中调用一切正常 public class Test { private static final Logger LOGGER = LogManager.getLogger(Test.class); public static void main(String[] args) { LOGGER.error("cuo wu"); } } 但是在servlet中使用就会报错 @WebServlet(urlPatterns = "/index") public class Test extends HttpServlet{ @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { final Logger LOGGER = LogManager.getLogger(); LOGGER.error("aefaefe"); resp.getWriter().write("hi"); } } 错误信息是 java.lang.NoClassDefFoundError: org/apache/logging/log4j/LogManager 希望有经验的大佬帮帮忙
查看完整描述

1 回答

?
慕容708150

TA贡献1831条经验 获得超4个赞

可以在项目的发布目录下找一下对应的class文件是否存在

查看完整回答
反对 回复 2019-03-01
  • 1 回答
  • 0 关注
  • 482 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信