Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running an exploded spring-boot jar from command line

I'm looking to run an exploded spring-boot jar. Currently I'm doing

jar xf app.jar
java -cp /lib/*:/ com/domain/module/Main

which seems to begin the app startup, but invariably stops on

[restartedMain] INFO c.a.a.spring.MetricsJersey2Config - Registering InstrumentedResourceMethodApplicationListener for jersey2 with MetricRegistry: com.codahale.metrics.MetricRegistry@43fee23e

The next line I'd usually expect to see is

[restartedMain] INFO o.s.s.c.ThreadPoolTaskExecutor - Initializing ExecutorService

Running the app using

java -jar app.jar

works fine, but for reasons I need to run it exploded.

Is there anything I'm missing in trying to run a spring-boot app this way?

like image 430
GBC Avatar asked Feb 24 '16 02:02

GBC


People also ask

Can I run spring boot executable jar from commandline?

To be able to run your Spring Boot app, you will need to first build it. To build and package a Spring Boot app into a single executable Jar file with a Maven, use the below command. You will need to run it from the project folder containing the pom. xml file.

How do I run a JAR file from the command line?

To run an application in a nonexecutable JAR file, we have to use -cp option instead of -jar. We'll use the -cp option (short for classpath) to specify the JAR file that contains the class file we want to execute: java -cp jar-file-name main-class-name [args …]


1 Answers

I solved this by running:

java -cp /lib/*:/ com.domain.module.Main

Rather than:

java -cp /lib/*:/ com/domain/module/Main
like image 193
GBC Avatar answered Oct 20 '22 18:10

GBC