Search code examples
mavenspring-bootspring-boot-maven-plugin

using spring-boot-maven-plugin with exec classifier, but can't run the app from IDE anymore


I am working on Spring Boot 1.5.9 application, and I am generating a jar that contains a Spring Boot application, but that can also be imported as part of another project.

Therefore, I am using below config to generate 2 jars : the exec, and the regular lib ones.

<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <configuration>
      <classifier>exec</classifier>
    </configuration>
</plugin>

However, now that I have this, I am not able to run the application from my IDE (Intellij) anymore, as it's not finding the application.yml.

I am sure there's a trick, but I can't find anything.. Any idea ?


Solution

  • I ended up using Maven profiles :

    <profiles>
        <profile>
            <id>makeRelease</id>
    
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.springframework.boot</groupId>
                        <artifactId>spring-boot-maven-plugin</artifactId>
                        <configuration>
                            <classifier>exec</classifier>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
    

    When I make the release, I am calling this profile (maven with argument -P makeRelease) so that it generates the 2 jars.

    The rest of the time, the regular behavior applies.