'GeoLite2 database gets corrupt when added to war

Like the question GeoLite2 database gets corrupt when added to jar, I got the error from the WAR file with the following steps:

  1. mvn package to copy GeoLite2-City.mmdb from src/main/resources/GeoLite2-City.mmdb to war file under WEB-INF/classes/GeoLite2-City.mmdb
  2. GeoLite2-City.mmdb was changed in the first step mvn package

I tried the plugin maven-resources-plugin as https://stackoverflow.com/a/34454312/1086907, but GeoLite2-City.mmdb is still changed by mvn package

How to troubleshoot the issue?



Solution 1:[1]

The maven-war-plugin can actually also filter that file.

Just like for the maven-resources-plugin, you can add that mmdb file extension as an additional extension not to be filtered:

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>3.2.0</version>
            <configuration>
                <nonFilteredFileExtensions>
                    <nonFilteredFileExtension>mmdb</nonFilteredFileExtension>
                </nonFilteredFileExtensions>
            </configuration>
        </plugin> 

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Tome