SpringBoot Static Resources Not Accessible After Packaging

Problem Description

After packaging SpringBoot into a jar file, static resources become inaccessible.

Solution

Add resource configuration in pom.xml:

<build>
    <resources>
        <resource>
            <!-- Copy jsp files to META-INF directory when packaging-->
            <!-- Specify which directory's resource files the resources plugin should handle -->
            <directory>src/main/resources</directory>
            <!--Must be placed here to be accessible-->
            <targetPath>META-INF/resources</targetPath>
            <includes>
                <include>**/**</include>
            </includes>
        </resource>
    </resources>
</build>