• 使用intellij idea导入项目时的问题小记


    记录这边文件,只是为了记录一些自己出现的错误,可能并不具有通性。

    使用intellij idea导入eclipsemaven项目出现了pom.xml文件错误,依赖包无法导入的错误,如下图所示:


    注:这里的jar包在maven的仓库里面都是有的。

    接下来,看到出错就不淡定了,然后各种调错。我找到了Maven project里面的install,然后进行安装,发现如下的错误:

    The requested profile "xxx" could not be activated because it does not exist.



    但是其实jar包在原有的项目当中就已经带有了,jar包如下图所示。


    那么既然有jar包了,就启动一下试试吧。这里需要配置下tomcat服务器(配置在这里就不说了)。

    当然第一步是需要编译了,


    点击红框当中的内容,就会对当前的项目进行make 编译。

    但是编译中发现缺少jar包。上面不是都有jar包了么,在这里,因为是eclipse项目导入到idea当中,所以对于这种有jar包的项目,我们需要添加配置classpath的路径指向lib目录。

    选择菜单栏File -> Project Structure出现如下图


    选择Modules->选中要添加jar包的项目->Dependencies->选择右边绿色+


    然后选中jar包所在目录,最后点击okay


    接下来会多出现如下的目录位置:


    最后点击Apply 即可。后面你就会发现所有编译报红的地方都没有了。说明jar包导入进来了。然后我们再编译项目。

    这个时候,项目编译就没有问题了,如果你得项目编译还有问题,那就说明jarlib目录下缺失,你应该下载对应的jar包放到lib目录下就可以了。

    好啦,编译已经通过了,那么接下来,就可以启动项目了。

    启动后,但是突然发现又报错了,在这里我贴出所有的错误代码:

    严重: ContainerBase.addChild: start: 
    org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/mobile-analysis]]
    	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:652)
    	at org.apache.catalina.startup.HostConfig.manageApp(HostConfig.java:1809)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    	at java.lang.reflect.Method.invoke(Method.java:498)
    	at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:301)
    	at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
    	at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
    	at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:618)
    	at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:565)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    	at java.lang.reflect.Method.invoke(Method.java:498)
    	at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:301)
    	at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
    	at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
    	at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1468)
    	at javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:76)
    	at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1309)
    	at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1401)
    	at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:829)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    	at java.lang.reflect.Method.invoke(Method.java:498)
    	at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:324)
    	at sun.rmi.transport.Transport$1.run(Transport.java:200)
    	at sun.rmi.transport.Transport$1.run(Transport.java:197)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at sun.rmi.transport.Transport.serviceCall(Transport.java:196)
    	at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:568)
    	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:826)
    	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:683)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:682)
    	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    	at java.lang.Thread.run(Thread.java:745)
    Caused by: java.lang.NoClassDefFoundError: Lorg/slf4j/Logger;
    	at java.lang.Class.getDeclaredFields0(Native Method)
    	at java.lang.Class.privateGetDeclaredFields(Class.java:2583)
    	at java.lang.Class.getDeclaredFields(Class.java:1916)
    	at org.apache.catalina.util.Introspection.getDeclaredFields(Introspection.java:106)
    	at org.apache.catalina.startup.WebAnnotationSet.loadFieldsAnnotation(WebAnnotationSet.java:270)
    	at org.apache.catalina.startup.WebAnnotationSet.loadApplicationServletAnnotations(WebAnnotationSet.java:139)
    	at org.apache.catalina.startup.WebAnnotationSet.loadApplicationAnnotations(WebAnnotationSet.java:65)
    	at org.apache.catalina.startup.ContextConfig.applicationAnnotationsConfig(ContextConfig.java:415)
    	at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:892)
    	at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:386)
    	at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
    	at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
    	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5416)
    	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    	... 42 more
    Caused by: java.lang.ClassNotFoundException: org.slf4j.Logger
    	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1720)
    	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571)
    	... 56 more
    
    七月 01, 2017 2:36:04 下午 org.apache.tomcat.util.modeler.BaseModelMBean invoke
    严重: Exception invoking method manageApp
    java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/mobile-analysis]]
    	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:904)
    	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
    	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)
    	at org.apache.catalina.startup.HostConfig.manageApp(HostConfig.java:1809)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    	at java.lang.reflect.Method.invoke(Method.java:498)
    	at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:301)
    	at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
    	at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
    	at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:618)
    	at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:565)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    	at java.lang.reflect.Method.invoke(Method.java:498)
    	at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:301)
    	at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
    	at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
    	at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1468)
    	at javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:76)
    	at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1309)
    	at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1401)
    	at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:829)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    	at java.lang.reflect.Method.invoke(Method.java:498)
    	at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:324)
    	at sun.rmi.transport.Transport$1.run(Transport.java:200)
    	at sun.rmi.transport.Transport$1.run(Transport.java:197)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at sun.rmi.transport.Transport.serviceCall(Transport.java:196)
    	at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:568)
    	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:826)
    	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:683)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:682)
    	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    	at java.lang.Thread.run(Thread.java:745)
    
    七月 01, 2017 2:36:04 下午 org.apache.tomcat.util.modeler.BaseModelMBean invoke
    严重: Exception invoking method createStandardContext
    javax.management.RuntimeOperationsException: Exception invoking method manageApp
    	at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:309)
    	at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
    	at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
    	at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:618)
    	at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:565)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    	at java.lang.reflect.Method.invoke(Method.java:498)
    	at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:301)
    	at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
    	at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
    	at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1468)
    	at javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:76)
    	at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1309)
    	at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1401)
    	at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:829)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    	at java.lang.reflect.Method.invoke(Method.java:498)
    	at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:324)
    	at sun.rmi.transport.Transport$1.run(Transport.java:200)
    	at sun.rmi.transport.Transport$1.run(Transport.java:197)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at sun.rmi.transport.Transport.serviceCall(Transport.java:196)
    	at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:568)
    	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:826)
    	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:683)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:682)
    	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    	at java.lang.Thread.run(Thread.java:745)
    Caused by: java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/mobile-analysis]]
    	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:904)
    	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
    	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)
    	at org.apache.catalina.startup.HostConfig.manageApp(HostConfig.java:1809)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    	at java.lang.reflect.Method.invoke(Method.java:498)
    	at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:301)
    	... 33 more
    
    [2017-07-01 02:36:04,650] Artifact mobile-analysis:war exploded: Error during artifact deployment. See server log for details.

    网上对于这一错误的说法是tomcat的版本不匹配,这里是有问题的。那么解决办法是什么呢,且听分解。

    主要是该项目的所有的jar包都是导入进来了,没错,但是项目并没有把所需要的lib添加到tomcat中。那么接下来解决

    点击File->Project Structure 然后点击对应Artifacts


    点击进入之后,出现如下的错误,意思是需要的lib下的jar包没有导入到artifact的包中:


    这个时候就点击Fix…,然后选择Add‘lib’ to the artifact


    好了,那么接下来,我们再来尝试下启动项目。如果还出现错误,就进如下图所示:

    这里应该是对应的web.xml文件没有匹配到项目当中来,那么还是进入File->project structure->Modules选择对应项目的web,如果没有就自己创建一个。

    然后创建完成以后,如下图:


    双击Web Resource Directory下面的目录,没有就自己创建一个,将如下的目录对应到web.xml文件所在的目录。

    这个时候再启动项目,就顺利启动了,这是我在启动时遇到的一些问题。如果是强迫症的程序猿们,在这里无解,因为pom.xml文件和dependency还是会报错。不过,给你提个建议,可以新建一个maven项目,把所有的需要的项目内容都添加进去应该就没什么问题了。



    学习、成长
  • 相关阅读:
    H3C利用dhcp snooping来禁用某个端口下的DHCP
    onu侧各种pon协议下的技术参数10G
    常见Intel网卡芯片对比,多队列网卡介绍
    esxi6.7 7.0 diy for nvme drivers
    Windows Server 2019 OVF 模板下载
    vSphere 6.5支持512e,NVMe SSD呢?
    何时使用领域驱动设计
    徒手打造基于Spark的数据工厂(Data Factory):从设计到实现
    早产的《HelloGitHub》第 65 期
    最简单的人工神经网络
  • 原文地址:https://www.cnblogs.com/yarcl/p/11046777.html
Copyright © 2020-2023  润新知