简体   繁体   中英

Run Spring's .class instead of .jar file

I have a Java Spring application which I built with maven , and a .jar file together with .class files were generated.

Instead of running the .jar file, is there a way for me to run the .class files instead?

I tried executing java -cp . hello.Application java -cp . hello.Application in the same directory as the Application.class (source code of Application.java below), but was given Error: Could not find or load main class hello.Application . Removing the hello. did not work either.

package hello;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class Application {

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }
}

我正在做Spring boot应用程序。我想你也可以使用maven创建一个jar文件,然后使用linux命令来运行它。

you can run a class by executing follow command :

java Application

for only simple console application. to run Spring Boot application you need maven to build jar file and executing jar file to call main method to load spring boot context. Spring Boot need several requirements and dependencies to run. Spring load context and create a special structure to load. for more you can see following links:

https://spring.io/guides/gs/spring-boot/

http://www.logicbig.com/tutorials/spring-framework/spring-boot/boot-exploded-structure/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM