Java – spring boot – how to specify an alternate boot class? (multiple entry points)

I want to add an alternative entry point to my spring boot application I'd rather think of it as a fat pot Is that possible?

According to their documentation, the attribute loader Main specifies the name of the main class to start

I try Java - jar myjar jar –loader. main = com. mycompany. Alternatemain, but my POM The start classes specified in POM. XML are still running (if I remove it from POM. XML, I made an error when packaging)

Or, I try Java - CP myjar jar com. mycompany. Alternatemain, but I don't know a good way to add all nested jars to the classpath

Any suggestions?

Editor: This is the solution I use

As JST suggested, I changed my launcher to use propertieslauncher I do this by modifying the configuration of my spring boot Maven plugin

<plugin>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-maven-plugin</artifactId>
  <configuration>
    <mainClass>${start-class}</mainClass>
    <layout>ZIP</layout>
    ...

I created my fat pot (MVN package) and then called the replacement host, as shown below.

java -jar -Dloader.main=com.mycompany.AlternateMain MyJar.jar

Thank you for your help!

Solution

I don't believe the property will apply to your situation There are 3 different "emitters" (return to the document and see) If you are building a jar, it will use the jarlauncher class If you switch it to propertieslauncher, then loader Main will be useful

Meta-INF / MANIFEST. MF

Main-Class: org.springframework.boot.loader.PropertiesLauncher
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>