Specify main class Spring-Boot command line

前端 未结 3 1684
-上瘾入骨i
-上瘾入骨i 2021-02-01 06:11

I use maven plugin to set the main class like this :


org.springframework.boot
spring-boot-maven-p         


        
相关标签:
3条回答
  • 2021-02-01 06:42

    There's a launcher for that in Spring Boot already. You need to build the jar with that as the Main-Class (by setting the layout in the build config).

    0 讨论(0)
  • 2021-02-01 06:56

    Executing from Windows PowerShell I needed this format (with the quotes):

    java -cp .\myjarfile.jar -D"loader.main=com.app.etc.FullyQualifiedMainClass" org.springframework.boot.loader.PropertiesLauncher

    To clarify the accepted answer: You can directly modify the loader.main property in the jar's META-INF/MANIFEST.MF file, if you're ok with a more static solution.

    0 讨论(0)
  • 2021-02-01 06:59

    Following command will do the trick:

    java -cp my-app.jar -Dloader.main=myApplicationClass org.springframework.boot.loader.PropertiesLauncher
    
    0 讨论(0)
提交回复
热议问题