IDEA MAVEN 專案 打包檔案到指定目錄
阿新 • • 發佈:2019-01-01
像上一篇文章,我們提到的,IDEA MAVEN struts專案中,如果我們把 struts.xml 檔案放在 src 目錄下,編譯的時候,將無法打包到 *\WEB-INF\classes* 路徑下,執行程式的時候自然就會報錯(404的錯誤,如下圖:)
建議大家先看目錄,再按步驟操作。重點內容
1. struts.xml 檔案無法打包到 \WEB-INF\classes\
2. 無法打包 struts.xml 檔案 導致執行報錯
控制檯異常資訊,見附錄。
3.MAVEN專案 打包到指定路徑 解決方案
設定步驟如下:
FILE -> Project Structure
-> 點選 + 號 -> 選擇 File -> 找到 struts.xml 檔案 -> ok ,
這樣我們便可以設定 將 指定檔案 打包到指定目錄了。
4.設定後,檢視打包結果
5.附錄
找不到 struts.xml ,控制檯報錯如下:
org.apache.catalina.LifecycleException: Failed to start component [org.apache .catalina.webresources.StandardRoot@4347694b]
at org.apache.catalina.util.LifecycleBase.handleSubClassException(LifecycleBase.java:441)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:198)
at org.apache.catalina.core.StandardContext.resourcesStart(StandardContext.java:4758 )
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:4893)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:740)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:716)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:703)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:620)
at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1832)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:112)
at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:530)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:429)
at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1622)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:304)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:123)
at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1172)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1394)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1398)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1366)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.IllegalArgumentException: The main resource set specified [D:\MyProject\java\_project\mavenstruts2\target\mavenstruts2] is not valid
at org.apache.catalina.webresources.StandardRoot.createMainResourceSet(StandardRoot.java:749)
at org.apache.catalina.webresources.StandardRoot.startInternal(StandardRoot.java:706)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
... 22 more