startup failed due to previous errors
IDEA搭建SSM项目服务器报:startup failed due to previous errors
第一次遇到这种问题,Tomcat打印出的信息极少,网上搜索了下,在WEB-INF目录下添加classes目录,在classes目录创建logging.properties,如下
logging.properties内容:
handlers = org.apache.juli.FileHandler, java.util.logging.ConsoleHandler ############################################################ # Handler specific properties. # Describes specific configuration info for Handlers. ############################################################ org.apache.juli.FileHandler.level = FINE org.apache.juli.FileHandler.directory = ${catalina.base}/logs org.apache.juli.FileHandler.prefix = error-debug. java.util.logging.ConsoleHandler.level = FINE java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
得到了报错信息:java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
执行后,在WEB-INF在增加了lib目录,里面是项目引用的jar包,点击OK。
实际在Idea中这样配置:
File > Project Structure > Artifacts > 在右侧Output Layout右击项目名,选择Put into Output Root,见下面截图:
重启Tomcat,java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener这个错误不报了。
但是,又报了一个错误:
Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from file[D:\code\newstart\out\artifacts\newstart_war_exploded\WEB-INF\classes\spring\applicationContext-mybatis.xml]; nested exception is java.lang.NoClassDefFoundError: org/springframework/context/event/EventListenerFactory
Caused by: java.lang.NoClassDefFoundError: org/springframework/context/event/EventListenerFactory
查看spring-context-3.2.4.RELEASE.jar org/springframework/context/event/* 并不存在EventListenerFactory
把spring-context-3.2.4.RELEASE.jar 换成spring-context-4.3.9.RELEASE.jar
问题解决