我正在使用 Apache Tomcat 开发网络应用程序。我的网络应用程序有一个 META-INF 目录,其中包含 context.xml 文件。问题是,当我尝试使用命令“jar -cvf mywebapp.war”创建 .war 文件时。 ,我收到此警告(我正在尽可能地翻译成英文):
META-INF will be ignored
adding META-INF/context.xml(in = 142)(compression 17%)
META-INF/MANIFEST.MF will be ignored
自从我启动 Tomcat 后出现了一些错误,我想可能都是因为这个警告。谢谢。
编辑:
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="mywebapp" version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<display-name>My web app</display-name>
<description>...</description>
<welcome-file-list>
<welcome-file>html/index.html</welcome-file>
</welcome-file-list>
<!-- Define the roles we want to use in the application -->
<security-role>
<role-name>member</role-name>
</security-role>
<security-constraint>
<!-- Define the resource -->
<web-resource-collection>
<web-resource-name>Members Only</web-resource-name>
<url-pattern>html/members/*</url-pattern>
</web-resource-collection>
<!-- Only members can access this resource -->
<auth-constraint>
<role-name>member</role-name>
</auth-constraint>
<user-data-constraint>
<!-- transport-guarantee can be CONFIDENTIAL, INTEGRAL, or NONE -->
<transport-guarantee>NONE</transport-guarantee>
</user-data-constraint>
</security-constraint>
<!-- Use BASIC security -->
<login-config>
<auth-method>BASIC</auth-method>
<realm-name>Secure area</realm-name>
</login-config>
</web-app>
最佳答案
尝试在 <url-pattern>
的开头添加斜杠对于 <security-constraint>
中的资源“仅限成员(member)”部分,例如:
<url-pattern>/html/members/*</url-pattern>
代替
<url-pattern>html/members/*</url-pattern>
关于tomcat - Apache Tomcat : META-INF directory ignored during creation of . war 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20708288/