web.xml is missing and <failOnMissingWebXml> is set to true

本文介绍了解决Maven项目WAR包构建时出现的failOnMissingWebXml错误的方法,包括检查web.xml文件的存在与否及配置maven-war-plugin等步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

参考:http://blog.youkuaiyun.com/liuvlun/article/details/50218507

使用maven创建项目时有时在pom.xml的war处出现failOnMissingWebXml的错误,根据错误提示的原因可以知道项目是web项目,打包时打成war包。

如果项目里没有web.xml,在项目里添加一个web.xml,刷新一下项目,就应该没有错误,如果还有请看下面的介绍

 如果你的项目在 /src/main/webapp/WEB-INF 下有web.xml,但是仍然还是报这个错误,需要两步操作

1)右击项目,打开Properties对话框,点击Deployment Assembly选项,在右边添加一个文件夹,并且保存设置

    2)在eclispe上方点击Project ->Clean 清理一下这个项目

经过这两步错误就应该已经清楚了

 

或者是

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</build>

 

转载于:https://www.cnblogs.com/bluedeblog/p/7401913.html

<?xml version="1.0" encoding="UTF-8"?> <!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <!-- Note: A "Server" is not itself a "Container", so you may not define subcomponents such as "Valves" at this level. Documentation at /docs/config/server.html --> <Server port="8005" shutdown="SHUTDOWN"> <Listener className="org.apache.catalina.startup.VersionLoggerListener" /> <!-- Security listener. Documentation at /docs/config/listeners.html <Listener className="org.apache.catalina.security.SecurityListener" /> --> <!--APR library loader. Documentation at /docs/apr.html --> <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" /> <!-- Prevent memory leaks due to use of particular java/javax APIs--> <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" /> <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" /> <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" /> <!-- Global JNDI resources Documentation at /docs/jndi-resources-howto.html --> <GlobalNamingResources> <!-- Editable user database that can also be used by UserDatabaseRealm to authenticate users --> <Resource name="UserDatabase" auth="Container" type="org.apache.catalina.UserDatabase" description="User database that can be updated and saved" factory="org.apache.catalina.users.MemoryUserDatabaseFactory" pathname="conf/tomcat-users.xml" /> </GlobalNamingResources> <!-- A "Service" is a collection of one or more "Connectors" that share a single "Container" Note: A "Service" is not itself a "Container", so you may not define subcomponents such as "Valves" at this level. Documentation at /docs/config/service.html --> <Service name="Catalina"> <!--The connectors can use a shared executor, you can define one or more named thread pools--> <!-- <Executor name="tomcatThreadPool" namePrefix="catalina-exec-" maxThreads="150" minSpareThreads="4"/> --> <!-- A "Connector" represents an endpoint by which requests are received and responses are returned. Documentation at : Java HTTP Connector: /docs/config/http.html Java AJP Connector: /docs/config/ajp.html APR (HTTP/AJP) Connector: /docs/apr.html Define a non-SSL/TLS HTTP/1.1 Connector on port 8080 --> <Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" /> <!-- A "Connector" using the shared thread pool--> <!-- <Connector executor="tomcatThreadPool" port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" /> --> <!-- Define an SSL/TLS HTTP/1.1 Connector on port 8443 This connector uses the NIO implementation. The default SSLImplementation will depend on the presence of the APR/native library and the useOpenSSL attribute of the AprLifecycleListener. Either JSSE or OpenSSL style configuration may be used regardless of the SSLImplementation selected. JSSE style configuration is used below. --> <Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol" maxThreads="150" SSLEnabled="true" scheme="https" secure="true"> <SSLHostConfig> certificateKeystoreFile="conf/keystore.jks" certificateKeystorePassword="changeit" type="RSA" /> </SSLHostConfig> </Connector> <!-- Define an SSL/TLS HTTP/1.1 Connector on port 8443 with HTTP/2 This connector uses the APR/native implementation which always uses OpenSSL for TLS. Either JSSE or OpenSSL style configuration may be used. OpenSSL style configuration is used below. --> <!-- <Connector port="8443" protocol="org.apache.coyote.http11.Http11AprProtocol" maxThreads="150" SSLEnabled="true" > <UpgradeProtocol className="org.apache.coyote.http2.Http2Protocol" /> <SSLHostConfig> <Certificate certificateKeyFile="conf/localhost-rsa-key.pem" certificateFile="conf/localhost-rsa-cert.pem" certificateChainFile="conf/localhost-rsa-chain.pem" type="RSA" /> </SSLHostConfig> </Connector> --> <!-- Define an AJP 1.3 Connector on port 8009 --> <!-- <Connector protocol="AJP/1.3" address="::1" port="8009" redirectPort="8443" /> --> <!-- An Engine represents the entry point (within Catalina) that processes every request. The Engine implementation for Tomcat stand alone analyzes the HTTP headers included with the request, and passes them on to the appropriate Host (virtual host). Documentation at /docs/config/engine.html --> <!-- You should set jvmRoute to support load-balancing via AJP ie : <Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1"> --> <Engine name="Catalina" defaultHost="localhost"> <!--For clustering, please take a look at documentation at: /docs/cluster-howto.html (simple how to) /docs/config/cluster.html (reference documentation) --> <!-- <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/> --> <!-- Use the LockOutRealm to prevent attempts to guess user passwords via a brute-force attack --> <Realm className="org.apache.catalina.realm.LockOutRealm"> <!-- This Realm uses the UserDatabase configured in the global JNDI resources under the key "UserDatabase". Any edits that are performed against this UserDatabase are immediately available for use by the Realm. --> <Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/> </Realm> <Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true"> <!-- SingleSignOn valve, share authentication between web applications Documentation at: /docs/config/valve.html --> <!-- <Valve className="org.apache.catalina.authenticator.SingleSignOn" /> --> <!-- Access log processes all example. Documentation at: /docs/config/valve.html Note: The pattern used is equivalent to using pattern="common" --> <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="localhost_access_log" suffix=".txt" pattern="%h %l %u %t "%r" %s %b" /> </Host> </Engine> </Service> </Server> 重启https还是连不上
06-27
@echo off setlocal enabledelayedexpansion :: Check if Launch4j is installed where launch4jc >nul 2>&1 if %ERRORLEVEL% neq 0 ( echo Error: launch4jc not found in PATH. Please install Launch4j and add it to PATH. pause exit /b 1 ) :: User input parameters set /p SOURCE_JAR_DIR=Enter source directory containing JAR file: set /p TARGET_EXE_DIR=Enter target directory for EXE output: set /p OUTPUT_NAME=Enter output name (without .exe): :: Set defaults if empty if "%SOURCE_JAR_DIR%"=="" set SOURCE_JAR_DIR=D:\1-information\source if "%TARGET_EXE_DIR%"=="" set TARGET_EXE_DIR=D:\1-information\target\aaa if "%OUTPUT_NAME%"=="" set OUTPUT_NAME=MyApp :: Normalize paths for %%i in ("%SOURCE_JAR_DIR%") do set SOURCE_JAR_DIR=%%~fi for %%i in ("%TARGET_EXE_DIR%") do set TARGET_EXE_DIR=%%~fi :: Find main JAR (assuming only one JAR in directory) set MAIN_JAR= for %%f in ("%SOURCE_JAR_DIR%\*.jar") do ( if "!MAIN_JAR!"=="" ( set MAIN_JAR=%%~nxf ) else ( echo Error: Multiple JAR files found. Please ensure only one main JAR exists. pause exit /b 1 ) ) if "%MAIN_JAR%"=="" ( echo Error: No JAR file found in directory: %SOURCE_JAR_DIR% pause exit /b 1 ) :: Find JRE environment (updated for JDK 17) set JRE_PATH= if defined JAVA_HOME ( :: Check for JDK 17+ structure if exist "%JAVA_HOME%\jre" ( set JRE_PATH=%JAVA_HOME%\jre ) else if exist "%JAVA_HOME%\bin\java.exe" ( :: Modern JDK (17+) has JRE embedded set JRE_PATH=%JAVA_HOME% ) ) if "%JRE_PATH%"=="" ( echo Warning: JRE not found. EXE will require Java to be installed. set BUNDLE_JRE=false ) else ( echo Found JRE at: %JRE_PATH% set BUNDLE_JRE=true ) :: Create temp working directory set TEMP_DIR=%TEMP%\%OUTPUT_NAME%_packager if exist "%TEMP_DIR%" ( echo Cleaning previous temp directory... rd /s /q "%TEMP_DIR%" ) mkdir "%TEMP_DIR%" mkdir "%TEMP_DIR%\lib" if "%BUNDLE_JRE%"=="true" mkdir "%TEMP_DIR%\jre" :: Copy JAR to temp directory echo Copying %MAIN_JAR% to temp directory... copy "%SOURCE_JAR_DIR%\%MAIN_JAR%" "%TEMP_DIR%\" >nul :: Copy dependencies (assuming in lib subdirectory) if exist "%SOURCE_JAR_DIR%\lib" ( echo Copying dependencies... xcopy /E /Y "%SOURCE_JAR_DIR%\lib" "%TEMP_DIR%\lib\" >nul ) :: Bundle JRE if found if "%BUNDLE_JRE%"=="true" ( echo Bundling JRE environment... xcopy /E /Y "%JRE_PATH%\*" "%TEMP_DIR%\jre\" >nul echo Bundling JRE environment999999999... ) :: Generate Launch4j config file with JDK 17+ support echo Generating configuration... ( echo <?xml version="1.0" encoding="UTF-8"?> echo <launch4jConfig> echo <dontWrapJar>false</dontWrapJar> echo <headerType>gui</headerType> echo <jar>%MAIN_JAR%</jar> echo <outfile>%OUTPUT_NAME%.exe</outfile> echo <errTitle>%OUTPUT_NAME% Error</errTitle> echo <cmdLine></cmdLine> echo <chdir>.</chdir> echo <priority>normal</priority> echo <downloadUrl>https://www.oracle.com/java/technologies/downloads/</downloadUrl> echo <supportUrl></supportUrl> echo <stayAlive>false</stayAlive> echo <restartOnCrash>false</restartOnCrash> echo <manifest></manifest> echo <icon></icon> echo <jre> echo <path>jre</path> echo <bundled>%BUNDLE_JRE%</bundled> echo <minVersion>17</minVersion> echo <maxVersion></maxVersion> echo <jdkPreference>preferJre</jdkPreference> echo <runtimeBits>64/32</runtimeBits> echo </jre> echo <versionInfo> echo <fileVersion>1.0.0</fileVersion> echo <txtFileVersion>1.0</txtFileVersion> echo <fileDescription>%OUTPUT_NAME%</fileDescription> echo <copyright>Copyright © %date:~0,4%</copyright> echo <productVersion>1.0.0</productVersion> echo <txtProductVersion>1.0</txtProductVersion> echo <productName>%OUTPUT_NAME%</productName> echo <companyName></companyName> echo <internalName>%OUTPUT_NAME%</internalName> echo <originalFilename>%OUTPUT_NAME%.exe</originalFilename> echo </versionInfo> echo </launch4jConfig> ) > "%TEMP_DIR%\config.xml" :: Run Launch4j with error handling echo Generating EXE file... cd /d "%TEMP_DIR%" call launch4jc config.xml if %ERRORLEVEL% neq 0 ( echo Error: Failed to generate EXE file (Exit Code: %ERRORLEVEL%) echo Possible causes: echo 1. Launch4j version doesn't support JDK 17+ echo 2. Missing required files echo 3. Insufficient permissions cd /d %~dp0 rd /s /q "%TEMP_DIR%" pause exit /b 1 ) :: Copy generated EXE to target directory if not exist "%TARGET_EXE_DIR%" mkdir "%TARGET_EXE_DIR%" echo Copying EXE to target directory... copy "%TEMP_DIR%\%OUTPUT_NAME%.exe" "%TARGET_EXE_DIR%\" >nul :: Copy complete package (with JRE and dependencies) echo Creating distribution package... xcopy /E /Y "%TEMP_DIR%" "%TARGET_EXE_DIR%\%OUTPUT_NAME%\" >nul :: Cleanup cd /d %~dp0 rd /s /q "%TEMP_DIR%" echo. echo ===== Packaging Successful ===== echo. echo Main EXE: "%TARGET_EXE_DIR%\%OUTPUT_NAME%.exe" echo Full package: "%TARGET_EXE_DIR%\%OUTPUT_NAME%\" echo. echo Note: If you bundled JRE, the total size may be large. echo. pause 中echo Bundling JRE environment999999999...未打印就给挂掉了
最新发布
07-11
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值