• eclipse下使用tomcat启动maven项目


    最近学习使用maven,建立了一个maven项目使用eclipse下tomcat启动时报错:

    严重: ContainerBase.addChild: start: 
    org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/SpringTest]]
    	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
    	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
    	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
    	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
    	at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:655)
    	at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1628)
    	at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
    	at java.util.concurrent.FutureTask.run(Unknown Source)
    	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    	at java.lang.Thread.run(Unknown Source)
    Caused by: java.lang.NoClassDefFoundError: org/springframework/context/ApplicationContext
    	at java.lang.Class.getDeclaredFields0(Native Method)
    	at java.lang.Class.privateGetDeclaredFields(Unknown Source)
    	at java.lang.Class.getDeclaredFields(Unknown Source)
    	at org.apache.catalina.util.Introspection.getDeclaredFields(Introspection.java:87)
    	at org.apache.catalina.startup.WebAnnotationSet.loadFieldsAnnotation(WebAnnotationSet.java:261)
    	at org.apache.catalina.startup.WebAnnotationSet.loadApplicationListenerAnnotations(WebAnnotationSet.java:90)
    	at org.apache.catalina.startup.WebAnnotationSet.loadApplicationAnnotations(WebAnnotationSet.java:65)
    	at org.apache.catalina.startup.ContextConfig.applicationAnnotationsConfig(ContextConfig.java:405)
    	at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:881)
    	at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:369)
    	at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
    	at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
    	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5173)
    	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    	... 10 more
    Caused by: java.lang.ClassNotFoundException: org.springframework.context.ApplicationContext
    	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714)
    	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
    	... 24 more
    

    同时,若在eclipse中右键export导出war包时,会发现war包中没有maven管理的lib包。

    这是由于没有将maven包配置为可导出造成的。需要打开.classpath文件,找到

    <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER" />
    

     改为

    <classpathentry export="true" kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
    	<attributes>
    		<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
    	</attributes>
    </classpathentry>
    

     如果元素中已有其他attribute,则直接在<attributes>下面增加<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>即可。

  • 相关阅读:
    ORA-01113: file xxxx needs media recovery
    ORACLE快速彻底Kill掉的会话
    fdisk添加分区引起的Linux Error: 22: Invalid argument
    VMware下Windows Server 2012添加新磁盘
    MS SQL 监控错误日志的告警信息
    【转载】latch: cache buffers chains
    SQL*Plus环境变量设置浅析
    Red Hat Enterprise Server 6.0 安装Sendmail相关包
    Python isinstance判断对象类型
    python strip()函数
  • 原文地址:https://www.cnblogs.com/wy2325/p/5011949.html
Copyright © 2020-2023  润新知