metadata-complete="true"

本文介绍了一个在web.xml中可能导致servlet无法被调用的问题。问题出现的原因是在web应用配置文件中添加了metadata-complete=true属性,这会导致服务器启动时不扫描注解,使得通过注解配置的servlet失效。

今天更新别人代码后,发现之前写的servlet调用不通了

然后发现web.xml里的头加了一个metadata-complete="true"属性


<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0" metadata-complete="true">


在网上查了下,发现

metadata-complete="true",会在启动时不扫描注解(annotation)。如果不扫描注解的话,用注解进行的配置就无法生效,例如:@WebServlet


代码都是@WebServlet这样写的,所以请求不到了


至于metadata-complete属性及相关的说明请看

https://www.ibm.com/developerworks/cn/java/j-lo-servlet30/







                
[root@docker yum.repos.d]# docker build -t="centos7-ssh" . #镜像名可自定义 [+] Building 12.2s (5/12) docker:default => [internal] load build definition from Dockerfile 0.0s => => transferring dockerfile: 574B 0.0s => [internal] load metadata for docker.io/library/centos:7.9.2009 0.0s => [internal] load .dockerignore 0.0s => => transferring context: 2B 0.0s => CACHED [1/9] FROM docker.io/library/centos:7.9.2009 0.0s => ERROR [2/9] RUN yum install -y openssh-server sudo 12.0s ------ > [2/9] RUN yum install -y openssh-server sudo: 0.984 Loaded plugins: fastestmirror, ovl 1.276 Determining fastest mirrors 11.83 Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=container error was 11.83 14: curl#6 - "Could not resolve host: mirrorlist.centos.org; Unknown error" 11.84 11.84 11.84 One of the configured repositories failed (Unknown), 11.84 and yum doesn&#39;t have enough cached data to continue. At this point the only 11.84 safe thing yum can do is fail. There are a few ways to work "fix" this: 11.84 11.84 1. Contact the upstream for the repository and get them to fix the problem. 11.84 11.84 2. Reconfigure the baseurl/etc. for the repository, to point to a working 11.84 upstream. This is most often useful if you are using a newer 11.84 distribution release than is supported by the repository (and the 11.84 packages for the previous distribution release still work). 11.84 11.84 3. Run the command with the repository temporarily disabled 11.84 yum --disablerepo=<repoid> ... 11.84 11.84 4. Disable the repository permanently, so yum won&#39;t use it by default. Yum 11.84 will then just ignore the repository until you permanently enable it 11.84 again or use --enablerepo for temporary usage: 11.84 11.84 yum-config-manager --disable <repoid> 11.84 or 11.84 subscription-manager repos --disable=<repoid> 11.84 11.84 5. Configure the failing repository to be skipped, if it is unavailable. 11.84 Note that yum will try to contact the repo. when it runs most commands, 11.84 so will have to try and fail each time (and thus. yum will be be much 11.84 slower). If it is a very temporary problem though, this is often a nice 11.84 compromise: 11.84 11.84 yum-config-manager --save --setopt=<repoid>.skip_if_unavailable=true 11.84 11.84 Cannot find a valid baseurl for repo: base/7/x86_64 ------ Dockerfile:4 -------------------- 2 | MAINTAINER mwf 3 | 4 | >>> RUN yum install -y openssh-server sudo 5 | RUN sed -i &#39;s/UsePAM yes/UsePAM no/g&#39; /etc/ssh/sshd_config 6 | RUN yum install -y openssh-clients -------------------- ERROR: failed to solve: process "/bin/sh -c yum install -y openssh-server sudo" did not complete successfully: exit code: 1
最新发布
10-09
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值