2021-05-09 maven編譯錯誤war

當(dāng)我學(xué)習(xí)Ajax時候出現(xiàn)了錯誤

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-

plugin:2.1.1:war (default-war) on project CRPS: The specified web.xml file

'D:\WEB-INF\web.xml' does not exist-> [Help 1]

[ERROR]

[ERROR] To see the full stack trace of the errors, re-run Maven with the -e > switch.

[ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR]

[ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1]


如您所見,該插件在D:\ WEB-INF路徑中查找以獲取進行戰(zhàn)爭包裝所需的web.xml,這顯然是錯誤的地方。您需要通過在終端運行時傳遞-Dmaven.war.webxml = .... / WEB-INF / web.xml參數(shù)來明確指定,也可以通過添加以下內(nèi)容將配置放入pom中

as you can see the plugin is looking in D:\WEB-INF path to get the web.xml needed to do war packaging and that's obviously wrong place to look. you need to specify explicitly either by passing -Dmaven.war.webxml=..../WEB-INF/web.xml argument at runtime on the terminal or you could put the configuration in your pom by adding

<plugin>

? ? <groupId>org.apache.maven.plugins</groupId>

? ? <artifactId>maven-war-plugin</artifactId>

? ? <version>2.3</version>

? ? <executions>

? ? ? <execution>

? ? ? ? <phase>package</phase>

? ? ? ? <configuration>

? ? ? ? ? <webXml>..../WEB-INF/web.xml</webXml>

? ? ? ? </configuration>

? ? ? </execution>

? ? </executions>

? </plugin>


請注意:您不需要聲明絕對路徑,到項目pom的相對路徑就足夠了。用正確的路徑替換點。

我猜您沒有使用默認的Maven War項目布局,這就是為什么您會收到此錯誤的原因。如果是的話,默認情況下,插件將按照以下示例從src / main / webapp / WEB-INF / web.xml中獲取web.xml。

Please note: you don't need to declare the absolute path, relative path to your project pom should be sufficient.?Replace the dots with the correct path.

I am guessing your are not using the default maven war project layout and that is why you are getting this error. if you were, the plugin would have got the web.xml from src/main/webapp/WEB-INF/web.xml by default as per the below example.

pom.xml

? ? ?src

? ? ? main

? ? ? ? ? ? ? ?java

? ? ? ? ? ? ? ?resources

? ? ? ? ? ? ? ? ? ? ?????webapp

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? WEB-INF

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?????web.xml

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容