Maven: how to place resource file together with jar?

No plugin definitions needed, just edit the build resources:

<build>
    <resources>
        <!-- regular resource processsing for everything except logback.xml -->
        <resource>
            <directory>src/main/resources</directory>
            <excludes>
                <exclude>logback.xml</exclude>
            </excludes>
        </resource>
        <!-- resource processsing with a different output directory
             for logback.xml -->
        <resource>
            <directory>src/main/resources</directory>
            <includes>
                <include>logback.xml</include>
            </includes>
            <!-- relative to target/classes
                 i.e. ${project.build.outputDirectory} -->
            <targetPath>..</targetPath>
        </resource>
    </resources>
</build>

Reference:

  • process-resources
    (Maven Book)
  • <build><resources> (POM
    Reference)

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)