首页 > 解决方案 > How to run spring boot application in windows which is developed in eclipse in Ubuntu os?

问题描述

I'm new to spring boot. I have written code to display "hello world". HelloWorld1Application.java: package com.example.demo;

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

@SpringBootApplication
public class HelloWorld1Application {

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

AppConfiguration.java :

package com.example.demo;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class AppConfiguration {

@RequestMapping("/hello")
public String hello() {
    return "Hello World";
}
}

It runs fine in Eclipse ide. I have tried it in terminal n got proper output(java -jar target/HelloWorld1-0.0.1-SNAPSHOT.jar). Now I want to run this program in windows. How can i do that? Where can i find the bytecode of this application? How to execute it in command prompt of windows?

标签: javaspring-bootmaven

解决方案


  1. Copy HelloWorld1-0.0.1-SNAPSHOT.jar to windows
  2. Execute java -jar HelloWorld1-0.0.1-SNAPSHOT.jar in command prompt

Note: make sure you have JRE installed on windows machine.


推荐阅读