服务器和客户端软件包的Java项目中的共享资源 [英] Shared resources in a Java project for server and client packages

查看:91
本文介绍了服务器和客户端软件包的Java项目中的共享资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含服务器和客户端软件包的Java项目。另外我有一个库包。

I have a Java project that has both server and client packages. In addition I have a library package.

我使用eclipse并将所有内容放在一个Java项目中,每个部分服务器,客户端和库都在单独的包中,问题是当我导出时,一切都得到了添加到Jar文件。

I use eclipse and have put everything in a single Java project, each section server,client and library are in separate packages, the problem is that when I export, everything gets added to the Jar file.

所以我想我需要两个不同的项目,客户端和服务器,但共享库文件呢?我该怎么办?我真的需要三个不同的项目吗?它会变得有点笨拙,因为一切都是相关的,我想把它们放在一起。

So I suppose I need two different projects, client and server, but what about the shared library files? What do I do about them? Do I actually need three different projects? It will become a little unwieldy as everything is actually related and I would like to keep them together.

推荐答案


<我使用eclipse并将所有
放在一个java项目中,每个
服务器,客户端和库都在
单独的包中,问题是当我导出时
,所有东西都被添加到Jar文件中

I use eclipse and have put everything in a single java project, each section server,client and library are in separate packages, the problem is that when I export, everything gets added to the Jar file.

这是引起我兴趣的部分,为什么要导出一些东西有客户端和服务器? 从客户端 - 服务器的角度来看,它们将单独分发

This is the part that intrigued me, why are you exporting something that has both the client and the server? From a client-server perspective they are going to be distributed separately.


我真的需要三种不同的
项目?因为一切实际上与
有关,所以它会变得有点
笨拙,我想把它们保持在一起

Do I actually need three different projects? It will become a little unwieldy as everything is actually related and I would like to keep them together.

由于 IDE现在可以管理项目/模块之间的依赖关系,我认为它看起来不像你想象的那么糟糕。例如,您可以同时处理服务器代码,并使用客户端代码中的类和接口,并引用服务器项目生成的JAR。

Thanks to how IDEs can now manage dependencies across projects/modules, I don't think it looks as bad as you picture it. For example you can work simultaneously on the server code, and use its classes and interfaces from your client code, and reference JARs produced by the server project.

我想要还要补充一点,项目也不是最广泛的代码封装,还有一个工作区可以包含许多相关的项目。其他IDE使用其他措辞,如模块而不是项目。

I'd like also to add that a 'Project' isn't the broadest encapsulation of code either, there is still a 'Workspace' that can contain a number of related 'Projects'. Other IDEs go for other wordings like 'Module' instead of 'Project'.

结束思路:

对于阻抗最小的路径,我认为您应该将客户端和服务器部分分成两个项目,并且如果您正在编译它,请对共享库执行相同的操作。来源,即不是第三方JAR。

For the least impedance path, I think you should separate the client and the server parts into two projects, and do the same think for the shared library in case you are compiling it from source i.e, not a 3rd party JAR.

因此,在一天结束时,您将从编译过程中获得3个产品并将它们分配到它们所属的位置, '库'在两个分销方都重复。

So in the end of the day you will have 3 'products' from the compilation process and distribute them where they belong, with the 'library' duplicated on both distribution sides.

这篇关于服务器和客户端软件包的Java项目中的共享资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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