Android上的Spring Boot? [英] Spring Boot on Android?

查看:492
本文介绍了Android上的Spring Boot?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在Android设备上运行Spring Boot?

现在,我已经使用IntelliJ IDEA构建的Spring Boot在本地主机上成功运行了Web服务.我需要在Android设备上运行相同的Web服务代码.是否可以将Web服务应用程序构建为可以在Android手机上运行的JAR文件?我有一个运行Android Nougat的Google Nexus 6P.我进行了一些有限的研究,并找到了一个名为JBED的应用程序.到目前为止,我还无法正常工作.

Right now I am successfully running a web service on localhost using Spring Boot which I've got building in IntelliJ IDEA. I need to get the same web service code running on an Android device. Is it possible to build the web service app into a JAR file that I can get running on an Android phone? I have a Google Nexus 6P running Android Nougat. I've done some limited research, and have found an application called JBED. So far I haven't been able to get this working.

我从头开始构建了示例JAR:

I've started from scratch and built the example JAR:

gs-spring-boot-0.1.0.jar

希望我能找到一种运行此JAR的方法.我想这可能行不通,所以如果有人有更好的主意,那就太好了!

and hopefully I can find a way to run this JAR. I'm guessing it probably won't work so if anyone has a better idea that would be great!

推荐答案

简短的答案是,您将无法直接在Android手机上运行spring boot应用程序. Spring Boot旨在作为包装器来快速引导Spring应用程序,并且在构建基于Web的应用程序时将为您提供最佳服务.在我看来,您有两个选择.

Short answer is you're not gonna be able to directly run your spring boot application on your android phone. Spring boot is meant as a wrapper to quickly bootstrap Spring applications and is going to best serve you when building web based applications. As I see it you have two options.

  1. 将jar部署到某个地方的云中(ec2,digitalocean,heroku,cloud Foundry等),然后只需从android浏览器访问您的Spring MVC应用即可.如果您的启动应用程序中有一些非常复杂的逻辑,但您认为您无法移植到android,则仍然可以在云中部署启动应用程序,并创建一个真正的笨拙"的前端android应用程序,将其全部消耗掉.来自Spring Boot应用程序的数据在外部运行.
  2. 将当前的Spring Boot应用程序移植到真正的Spring for Android项目. http://projects.spring.io/spring-android/.可以使用工具来帮助您将其移植到所有要做的工作中.
  1. Deploy your jar on the cloud somewhere(ec2,digitalocean, heroku, cloud foundry, etc.) and just access your Spring MVC app from the android browser. If you have some really complex logic in your boot app that you don't think you can port to android, you can still deploy your boot app in the cloud, and create a really "dumb" front end android application that consumes all of it's data from the spring boot app running externally.
  2. Port you current spring boot application to a true Spring for Android project. http://projects.spring.io/spring-android/. The tools are out there to help you port it over all you have to do is put the work in.

这篇关于Android上的Spring Boot?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆