Maven created web app does not scan for annotations
I created webapp using maven and it behaved oddly. Whenever there is web.xml file, then annotations will be ignored. So if you have servlets not registered in web.xml but annotated, http requests won't be forwarded to them. Annotations are only scanned if you remove the web.xml. After hours of digging, I found out the root cause of the problem is because maven creates the most ancient version of web.xml which is version 2.3.
You need to have web.xml version 3 to make web.xml takes precedence over annotations while still having the servlet container scan for annotations.<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
<display-name>Archetype Created Web Application</display-name>
</web-app>
I am unaware of any earlier version of web.xml that behaves like version 3.<web-app 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_3_0.xsd"
version="3.0">
0 komentar:
Posting Komentar