默认选择的tomcat安装在了C盘下的C:\Program Files下
所以webapp文件也在C盘下
选择启动tomcat时
我选择了 bin下的 Tomcat.exe
显示成功启动
打开项目网站显示404 到webapp文件下发现未解压war文件
选择bin下的startup.bat打开tomcat 显示报错
-
java.io.IOException: Unable to create the directory [C:\Program Files\Apache Software Foundation\Tomcat8.0.1\webapps\Truck_Sim]
-
at org.apache.catalina.startup.ExpandWar.expand(ExpandWar.java:115)
-
at org.apache.catalina.startup.ContextConfig.fixDocBase(ContextConfig.java:619)
-
at org.apache.catalina.startup.ContextConfig.beforeStart(ContextConfig.java:752)
-
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:308)
-
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:95)
-
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
-
at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:394)
-
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:144)
-
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725)
-
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701)
-
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
-
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:940)
-
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1816)
-
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
-
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
-
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)
-
-
13-Feb-2017 17:18:13.926 WARNING [localhost-startStop-1] org.apache.catalina.core.StandardContext.postWorkDirectory Failed to create work directory [C:\Program Files\Apache Software Foundation\Tomcat8.0.1\work\Catalina\localhost\Truck_Sim] for context [/Truck_Sim]
c盘权限不够 无法解压
放到其他地方 或者修改权限
就能成功解压 并加载项目
另外 在conf文件夹下server.xml中
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true">
unpackWARs="true" 设置自动解压war
最后 如果还是不能自动解压
将war后缀改成zip 然后自己手动解压
然后启动tomcat
另 后续发现如果war文件名中带空格 也会出现解压失败的情况
Tomcat 没有自动解压webapp下的war项目文件问题
原文:http://www.cnblogs.com/austinspark-jessylu/p/7833648.html