我是 springboot 的新手,使用的是 springboot 2 版本。
我想在命令提示符下使用java -jar my-app-0.0.1-SNAPSHOT.jar运行我的 spring boot 应用程序。
但是,当我使用 eclipse 构建应用程序时,它直接调用 myService.getMyMethod() 并且不构建 jar。
我想先构建 jar 文件,然后从命令提示符运行java -jar my-app-0.0.1-SNAPSHOT.jar ,这将调用 myService.getMyMethod()
我已经在 pom.xml 中有 spring-boot-maven-plugin,运行mvn package / mvn install启动应用程序,但不会在目标文件夹中生成 jar 文件。mvn clean package 也不起作用,MyApplication 正在使用实现 CommandLineRunner 并开始调用构建方法,因此不生成构建 jar 文件
我的主要课程:
@SpringBootApplication
public class MyApplication implements CommandLineRunner {
private static String URL = "ws://localhost:8080/spring-mvc-java/chat";
@Autowired
private MyService myService;
public static void main(String[] args) {
SpringApplication.run(MyApplication.class, args);
}
@Override
public void run(String... args) throws …
Run Code Online (Sandbox Code Playgroud) java pom.xml spring-boot spring-websocket spring-boot-maven-plugin