我有一个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.ServerWhere 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.
更多推荐
发布评论