我们是否可以仅通过SSH将更改的类重新部署到JAR(Can we redeploy only changed classes to a JAR over SSH)

编程入门 行业动态 更新时间:2024-10-26 02:32:08
我们是否可以仅通过SSH将更改的类重新部署到JAR(Can we redeploy only changed classes to a JAR over SSH)

我有一个Android客户端/服务器程序,我正在使用IntelliJ作为我的IDE。

服务器,甚至用于测试,都在EC2主机上运行,​​因为我在各种各样的地方使用我的笔记本电脑,并且不想在任何地方设置端口转发!

我只是想知道是否有一种方便的方法来重新部署我的服务器代码而不必重新发送所有库以使其更快一些。

我将服务器作为.jar运行,即java -jar Server.jar

是不是有可能,我不知道,将一个jar中的所有库都只发送编译后的代码?

又名。

目前我只有一个罐子:

的server.jar

但我可以把它换成两个罐子吗?

libraries.jar server.jar

我只是重新加载并运行

的server.jar

可以吗?

*更新*

刚刚意识到我可以通过使用轻松实现这一点

java -cp ./libraries.jar -jar server.jar

但我会留下这个问题以防其他人有同样的心理打嗝

*更新2 *

好的,上面不工作! 关于-jar命令忽略外部库的奇怪之处:S(所以为什么要允许-cp标志??? !! Java就像民主一样 - 除了所有其他语言之外最糟糕的语言!)

但是,这样做:

java -cp server.jar:libraries.jar server.Server

其中server.Server是主类

请参阅访问外部Jar中的类

I have an Android client/server program that I'm building using IntelliJ as my IDE.

The server, even for testing, runs on an EC2 host, as I work on my laptop in a variety of places and don't want to set up port forwarding everywhere I go!

I'm just wondering if there's a convenient way to redeploy my server code without having to resend all the libraries to make it a bit quicker.

I run my server as a .jar, i.e. java -jar Server.jar

Is it possible to, I dunno, have all the libraries in one jar and only send the compiled code?

aka.

At the moment I have just one jar:

Server.jar

But could I change it to two jars?

libraries.jar server.jar

and I just reupload and run

server.jar

Can it be done?

* UPDATE *

Just realised I can easily achieve this by using

java -cp ./libraries.jar -jar server.jar

But I'll leave the question up in case someone else has the same mental hiccup

* UPDATE 2 *

Ok, THE ABOVE DOESN'T WORK! Something weird about the -jar command ignoring external libraries :S (so why allow the -cp flag ???!! Java is like democracy - the worst language except for all the others!)

However, this does:

java -cp server.jar:libraries.jar server.Server

Where server.Server is the Main Class

See Accessing classes in an external Jar

最满意答案

是非常可能,这就像一个补丁。

您不需要在一个罐子中重新组合库(如果它们都是第三方)。

已经设置了部署结构。 所以你只需要更换你正在改变的部分。

假设您在server.jar的类xyz中进行了一些更改,然后简单地将server.jar替换为新的并重新启动服务器。 这些变化将反映出来。

Yes very much possible, this is just like a patch.

You don't need to regroup libraries in a single jar (IF THEY ARE ALL THIRD PARTY).

As your deployment structure is already setup. So you just need to replace the part which you are changing.

Let's say you made some changes in class xyz of server.jar, then simply replace the server.jar with the new one and restart the server. The changes will reflect.

更多推荐

本文发布于:2023-07-09 14:55:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1087147.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:JAR   SSH   redeploy   classes   changed

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!