In general, for a Maven Java project, files with source files must be located in the src/main/resources subdirectory of the project. The contents of this resources directory are copied to the output directory ( target/classes by default) at the build-process stage.
For Maven WAR projects, this is somewhat more complicated: there is also a src/main/webapp directory in which Maven expects to find WEB-INF/web.xml . To create a WAR file, this file must exist; otherwise, you will see an error message that resembles the following:
[INFO] ------------------------------------------------------------------------ [ERROR] BUILD ERROR [INFO] ------------------------------------------------------------------------ [INFO] Error assembling WAR: webxml attribute is required (or pre-existing WEB-INF/web.xml if executing in update mode)
Since the WEB-INF must exist under src/main/webapp , I would recommend not defining it again in src/main/resources . Although this is perfectly true and the contents of the two directories will be merged, confusion may occur if the file is defined in both. The contents of src/main/resources will take precedence, as they are copied over the contents from src/main/webapp .
Rich Seller Aug 19 '09 at 8:47 2009-08-19 08:47
source share