membersound
membersound

Reputation: 86747

How to deploy static resources to tomcat without WEB-INF?

I want to create a war package that only contains static resources. Eg:

/src/main/resources/files/example.xml

Therefore, I created the following maven config:

<?xml version="1.0" encoding="UTF-8"?>
<project>
    <groupId>my.domain</groupId>
    <artifactId>testpackage</artifactId>
    <version>1.0.0</version>
    <packaging>war</packaging>

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

When deploying on tomcat8, I get the following structure:

localhost:8080/testpackage/WEB-INF/classes/files/example.xml

What I want is being able to access the static file directly using:

localhost:8080/testpackage/files/example.xml

Question: how could I create a deployable war that explodes in a path without /WEB-INF/classes?

(I know I could just copy the files into /webapps folder manually. But others should be able to deploy the static content just through the tomcat manager web interface, thus is need a proper war).

Upvotes: 0

Views: 1205

Answers (1)

JB Nizet
JB Nizet

Reputation: 691735

Web resources are under src/main/webapp.

src/main/resources is for classpath resources.

See the project layout documentation.

Upvotes: 2

Related Questions