title: Spring Boot - How to specify an alternate start-class? (Multiple Entry Points)
body: <p>I want to add an alternate entry point to my Spring-Boot application.  I would prefer to keep this as a fat jar.  Is this possible?</p>
  
  <p>According to their <a href="http://docs.spring.io/spring-boot/docs/current/reference/html/executable-jar.html" rel="noreferrer">documentation</a>, the property <code>loader.main</code> specifies the name of the main class to launch.</p>
  
  <p>I tried <code>java -jar MyJar.jar --loader.main=com.mycompany.AlternateMain</code> but the start-class specified in my pom.xml was still run (and if I remove this from the pom.xml then I error during the packaging).</p>
  
  <p>Alternatively, I tried <code>java -cp MyJar.jar com.mycompany.AlternateMain</code> but I don't know of a good way to add all the nested jars to the classpath.</p>
  
  <p>Any suggestions?</p>
  
  <p><strong>Edit:  Here is the solution that I used</strong></p>
  
  <p>As jst suggested, I changed my launcher to use the PropertiesLauncher.  I did this by modifying the configuration of my spring-boot-maven-plugin.</p>
  
  <pre><code>&lt;plugin&gt;
    &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
    &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;
    &lt;configuration&gt;
      &lt;mainClass&gt;${start-class}&lt;/mainClass&gt;
      &lt;layout&gt;ZIP&lt;/layout&gt;
      ...
  </code></pre>
  
  <p>The <code>&lt;layout&gt;ZIP&lt;/layout&gt;</code> <a href="https://stackoverflow.com/questions/36168310/how-to-specify-the-launcher-in-spring-boot-gradle">triggers Spring Boot to use the <code>PropertiesLauncher</code></a>.</p>
  
  <p>I created my fat jar (mvn package) then called the alternate main like this:</p>
  
  <pre><code>java -jar -Dloader.main=com.mycompany.AlternateMain MyJar.jar
  </code></pre>
  
  <p>Thanks for the help!</p>