我的工程有两个jar包是本地的, 采用eclipse的run on server正常启动(我把这两个jar加到 run Configuration 的Apache Tomcat v8.5 32 at localhost的classpath中),
但是采用war包发布正式环境后就提示找不到类
我的pom.xml
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
<failOnMissingWebXml>false</failOnMissingWebXml>
<webResources>
<resource>
<directory>${project.basedir}/libs</directory>
<targetPath>WEB-INF/lib</targetPath>
<filtering>true</filtering>
<includes>
<include>**/*.jar</include>
</includes>
</resource>
</webResources>
</configuration>
</plugin>
.....
<dependency>
<groupId>com.tencent.lib</groupId>
<artifactId>TencentFetchLib</artifactId>
<version>1.0.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/libs/fetchlib/TencentFetchLib.jar</systemPath>
</dependency>
<dependency>
<groupId>com.android.dzh</groupId>
<artifactId>dzhcore</artifactId>
<version>5.8.5</version>
<scope>system</scope>
<systemPath>${project.basedir}/libs/dzh/dazhihui_5_85_dex2jar-m.jar</systemPath>
</dependency>
生成的war包,在WEB-INF\lib下确实有那两个jar包所在的目录dzh和fetchlib,里面jar都在,但是引用不到他们。
我强行将dzh和fetchlib目录下的jar复制到WEB-INF\lib下来,但是启动tomcat不了,报错:
02-May-2017 15:07:44.215 严重 [main] org.apache.catalina.startup.Catalina.start The required Server component failed to start so Tomcat is unable to start.
org.apache.catalina.LifecycleException: Failed to start component [StandardServer[8005]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
at org.apache.catalina.startup.Catalina.start(Catalina.java:656)
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.catalina.startup.Bootstrap.start(Bootstrap.java:355)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:495)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardService[Catalina]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:793)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 7 more
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
at org.apache.catalina.core.StandardService.startInternal(StandardService.java:422)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 9 more
Caused by: org.apache.catalina.LifecycleException: A child container failed during start
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:947)
at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 11 more
我发现这篇比较类似:https://nutz.cn/yvr/t/7p0a5gtjtkgtsq38s6pe6b11ja
但是我这打包没有问题,参考价值不大
在tomcat里,正确的引入maven本地jar的姿势是怎样的?
先谢谢啦!