java - 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?
解决方案
- Copy
HelloWorld1-0.0.1-SNAPSHOT.jar
to windows - Execute
java -jar HelloWorld1-0.0.1-SNAPSHOT.jar
in command prompt
Note: make sure you have JRE installed on windows machine.
推荐阅读
- vscode-remote - Remote SSH 在远程机器上安装了什么?
- php - 接受并记录收到的 HTML 电子邮件表单中的条件值
- php - 如何将 sql 查询分离成链方法
- c# - 在 Xamarin 表单中获取本地图像的路径
- css - TailwindCSS 响应式断点在 Vue 中不起作用
- javascript - 当我的整个页面都有“位置:绝对”时,如何检查我是否在顶部?
- mongodb - 猫鼬模式声明与不同的嵌套模式数组
- node.js - 获取错误:uncaughtException:source.on 不是函数,当对 multipart/form-data 使用请求和多方时
- php - 如何用苹果授权码换取访问令牌?
- java - java.lang.RuntimeException:无法为 Kotlin MainActivity 实例化活动 ComponentInfo